active record and same column name

in this example of tutorial how to fetch create time of comment and post table when we have $posts?

in this example post and comment have createtime field and query is


when i echo $posts->cretaetime i got create time of post table

Yeah, you’re asking the post what it’s createtime is, if you want the the comment create time you’d need

foreach ($post->comments as $comment) {

  echo $comment->createtime;


or something similar.

Hope I helped, I wasn’t sure if this is what you were asking.