Ejemplo n.º 1
0
 public function getMostRecentPostTimeAttribute()
 {
     $result = false;
     $latestPost = Post::select('time')->where('topic_id', $this->id)->orderBy('time', 'dec')->first();
     if ($latestPost) {
         $result = $latestPost->time;
     }
     return $result;
 }
Ejemplo n.º 2
0
 public function getMostRecentPostAttribute()
 {
     $post = null;
     $topicIDs = Topic::select('id')->where('section_id', $this->id)->get()->toArray();
     $postID = Post::select('id')->whereIn('topic_id', $topicIDs)->orderBy('id', 'desc')->get()->first();
     if ($postID) {
         $post = Post::find($postID->id);
     }
     return $post;
 }