Skip to content

Only sort in one direction (or change the first-click sort direction) #1003

Closed Answered by lrljoe
logcabintech asked this question in Q&A
Discussion options

You must be logged in to vote

This will prevent a column "last_seen" from being sorted in ascending order, by always causing it to sort in a descending manner, or else be unsorted.

Column::make("Last Seen", 'last_seen')
        ->sortable(
            fn(Builder $query, string $direction) => $query->orderBy('last_seen', "desc")
),

Replies: 1 comment 3 replies

Comment options

lrljoe
Jan 6, 2023
Collaborator Sponsor

You must be logged in to vote
3 replies
@dirtbikr
Comment options

@logcabintech
Comment options

@lrljoe
Comment options

lrljoe Jan 16, 2023
Collaborator Sponsor

Answer selected by logcabintech
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants