Can't get this to work properly. The results are not ordered by date and I get duplicates for each comment and view. This is what I'm using.
public static function getComments($id) {
$comments = DB::table('revisions')
->join('comments', 'comments.photo_id', '=', 'revisions.id')
->join('views', 'pid', '=', 'revisions.id')
->select('comments.comment', 'comments.uname', 'comments.id',
'comments.created_at as comments_date', 'views.user', 'views.created_at as views_date')
->where('revisions.id', '=', $id)
->orderBy('comments_date', 'desc', 'views_date', 'desc')
->get();
return $comments;
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community