Closed
Description
I want to fetch records and it works fine, but I want to sort it with a particular column.
so I tried this in my schema -
protected $defaultSort = '-createdAt';
but this is not sorting the records, I also tried with other column names, no luck.
in my controller index function
if I use
$spaces = $spaces->where('user_id', $user->id);
$spaces = $spaces->sort('createdAt');
error attached below is received. (where condition works fine, only sort is triggering that error).
I do not want to handle sort from the url like GET /spaces?sort=-createdAt HTTP/1.1
.
Please guide.
Metadata
Metadata
Assignees
Labels
No labels