Issue
It's been a few days since the Laravel released its latest version 6. I am trying to implement Laravel LazyCollection instead of the normal Collection class.
Following line works-
Drug::where('deactive',0)->orderBy('code')->get();
And when I use
Drug::cursor()->where('deactive',0)->orderBy('code')->get();
I get an error Method Illuminate\Support\LazyCollection::orderBy does not exist.
Can anyone help me how to use OrderBy with LazyCollection?
UPDATE
After getting the answer here is the correct syntax of above query
Drug::cursor()->where('deactive',0)->sortBy('code');
Solution
Offcourse, orderBy
method is Query builder method. You can use sortBy
as defined in the docs
Answered By - guttume Answer Checked By - Cary Denson (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.