many to many where query doesn't work when used order by laravel code example
Example: laravel orderby with relation
$users = User::with(['student' => function ($q) {
$q->orderBy('id', 'desc');
}]);
$users = User::with(['student' => function ($q) {
$q->orderBy('id', 'desc');
}]);