Laravel 发布其最新版本 6 已经有几天了。我正在尝试实现 Laravel LazyCollection 而不是普通的 Collection 类。
以下线路工作 -
Drug::where('deactive',0)->orderBy('code')->get();
当我使用
Drug::cursor()->where('deactive',0)->orderBy('code')->get();
我收到一个错误Method Illuminate\Support\LazyCollection::orderBy does not exist.
谁能帮助我如何将 OrderBy 与 LazyCollection 一起使用?
更新
在这里得到答案后是上述查询的正确语法
Drug::cursor()->where('deactive',0)->sortBy('code');