Sort Eloquent query by sub-relationship's latest()
I'm able to sort a query by one of its relationships foos :
return new UserResource(
User::with([
'foos' => function ($q) { $q->latest(); },
'foos.bar',
])->find($user_id)
);
But actually, I need to sort it by it's subrelationshipbar. Knowing that a foo can only have one bar.
How can I modify my code to order by foos.bar 's latest() ?