Kyslik / column-sortable

Package for handling column sorting in Laravel 5/6/7/8
MIT License
641 stars 105 forks source link

Custom default sort direction #200

Closed ezra-obiwale closed 2 years ago

ezra-obiwale commented 2 years ago

Ensures overriding the direction in the query parameter works as expected.

@sortablelink('column', 'columnTitle', ['direction' => 'desc'])
Darthmaul commented 2 years ago

Hello - I would really love to see this PR implemented. I just got a request from a user to implement this functionality and this PR would resolve. Thanks for your work!

robbielove commented 2 years ago

This is already possible by passing direction as an associative array to the third parameter:

$columnSpecificData['name'] = ['direction' => 'desc'];

@sortablelink('name', 'Name', $columnSpecificData['name'])

$columnSpecificData['other'] = ['direction' => 'asc'];

@sortablelink('other', 'Other', $columnSpecificData['other'])
ezra-obiwale commented 2 years ago

@robbielove I tested it as you mentioned above however, the direction was still being overridden by the determined direction.

I've updated this PR to fix that.

robbielove commented 2 years ago

yeah sorry it's in other PR's

see #188 #194

ezra-obiwale commented 2 years ago

Cool. Shutting this down then.

Could you maybe see about merging one of those PRs? Thanks.