lifeonscreen / nova-sort-relations
This package improves support for sorting relations in Laravel Nova.
Installs: 74 082
Dependents: 0
Suggesters: 0
Security: 0
Stars: 20
Watchers: 3
Forks: 9
Open Issues: 4
Requires
- php: >=7.1.0
This package is auto-updated.
Last update: 2024-10-29 04:20:16 UTC
README
This package improves support for sorting relations in Laravel Nova.
Installation
Install via composer
$ composer require lifeonscreen/nova-sort-relations
Usage
Include LifeOnScreen\SortRelations\SortRelations
trait to your class. Define base by overriding indexQuery
.
Define sortable columns in $sortRelations
array.
... use LifeOnScreen\SortRelations\SortRelations; ... class Product extends Resource { public static $sortRelations = [ // overriding id with product.id (this prevent ambiguous id, if you select multiple ids) 'id' => 'product.id', // overriding user relation sorting 'user' => [ // sorting multiple columns 'users.name', 'users.surname', ], // overriding company relation sorting 'company' => 'company.name', ]; public static function indexQuery(NovaRequest $request, $query) { // You can modify your base query here. return $query; } }
Security
If you discover any security-related issues, please email the author instead of using the issue tracker.
Credits
License
MIT license. Please see the license file for more information.