Reputation: 892
In laravel5 I need to put orderBy and where clause together, as in:
$patches = Patch::orderBy('PatchCode', 'DESC')
->where('AccountID', '=', Auth::user()->AccountID)->get();
But orderBy is not working. How can I achieve that?
Upvotes: 1
Views: 5022
Reputation: 2667
Here is the code which will definitely work. Just put the orderBy at the end. Like:
$patches = Patch::where('AccountID', '=', Auth::user()->AccountID)
->orderBy('PatchCode', 'DESC')
->get();
Upvotes: 2