Skip to content

Default or custom sort not working. #88

Closed
@sahil-kindlebit

Description

@sahil-kindlebit

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.

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions