$activities = Activity::where('relation_id','=',$request->id)
->with(['reactions.user' => function($query) {
$query->latest();
},
'posts.assignedUsers' => function($query) {
$query->latest();
},
'notities.user' => function($query) {
$query->latest();
},
'cat' => function($query){
$query->latest();
},
'relations' => function($query){
$query->latest();
}])
->get();
Sep 5, 2018
3
Level 1
Ordering multiple relationships on created_at date
I am calling a lot of relationships through my activity feed model --- however, I want all of them to be ordered by the created_At date.
I can't seem to succeed with this. anyone has an idea how to do this?
$activities = Activity::where('relation_id','=',$request->id)->with('reactions.user')->with('posts.assignedUsers')->with('notities.user')->with('cat')->with('relations')->orderBy('created_at','desc')->get();
Level 9
Please or to participate in this conversation.