I have two queries with Eloquent which I collect and merge and after i do sortByDesc
but it's not sorting collection.
$f_games = collect(Game::with('fUser', 'sUser')->where('first_user_id', Auth::user()->id)>get());
$s_games = collect(Game::with('fUser', 'sUser')->where('second_user_id', Auth::user()->id)->get());
$response = $f_games->merge($s_games)->sortByDesc('id');
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire