When i try ordernate the output data using orderBy() eloquent's method, i view the follow message: BadMethodCallException: Method Illuminate\Database\Eloquent\Collection::orderBy does not exist. in file C:\xampp\htdocs\cerusbank\vendor\laravel\framework\src\Illuminate\Macroable\Traits\Macroable.php on line 103.
The following is my method I'm working on:
public function getCardStatements(Request $request){
if($request->id){
$cardStatements = Card::with('statements')->where('id', $request->id)->get();
return response()->json($cardStatements->orderBy('statements.registration_date', 'asc'));
}
return response()->json(array('return'=>false));
My Answer:
>orderBy('created_at', 'desc')->get();
return $cardStatements;
}
Rate this post
3 of 5 based on 5847 votesComments