Reputation: 141
I want to sort my data by created date with this code :
$comments = Instacomment::where('postid',$query->post['id'])->orderBy('comment.created_at', 'ASC')->paginate(10);
These are the results and Laravel gives me duplicate data! I don't know what to do !
Upvotes: 1
Views: 251
Reputation: 461
please try join table
$comments = Instacomment::join('comments', 'instacomment.id', '=', 'comments.postid')->where('postid',$query->post['id'])->orderBy('comment.created_at', 'ASC')->paginate(10);
Upvotes: 2