stephenjude / default-model-sorting
Add default sorting column to your eloquent model
Installs: 70 603
Dependents: 0
Suggesters: 0
Security: 0
Stars: 35
Watchers: 3
Forks: 4
Open Issues: 0
Requires
- illuminate/support: ^8.0|^9.0|^10.0|^11.0
Requires (Dev)
- orchestra/testbench: ^6.0|^7.0
- phpunit/phpunit: ^9.0|^10.0|^11.0
This package is auto-updated.
Last update: 2024-10-27 16:27:20 UTC
README
Add default sorting column to your eloquent model.
Installation
You can install the package via composer:
composer require stephenjude/default-model-sorting
Basic Usage
use Stephenjude\DefaultModelSorting\Traits\DefaultOrderBy; class Article extends Model { use DefaultOrderBy; protected static $orderByColumn = 'title'; }
Column Sorting Order
You can change the default column sorting order by adding the $orderByColumnDirection
property inside your eloquent model.
use Stephenjude\DefaultModelSorting\Traits\DefaultOrderBy; class Article extends Model { use DefaultOrderBy; protected static $orderByColumn = 'title'; protected static $orderByColumnDirection = 'desc'; }
Configurations
Publishing Config
You can publish the config file by running the vendor:publish command
php artisan vendor:publish --provider="Stephenjude\DefaultModelSorting\DefaultModelSortingServiceProvider" --tag="config"
Configuring Default Column Sorting Order
You can change the default sorting order inside the config file:
'order_by' => 'asc',
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email hello@stephenjude.me instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.