BadMethodCallException: 方法 Illuminate\Database\Eloquent\Collection::orderBy 不存在。

3

在尝试使用Eloquent的orderBy()方法对输出数据进行排序时,我看到了以下消息: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.

以下是我正在处理的方法:

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));
1个回答

5

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接