hnhdigital-os / laravel-model-filter
Provides model attribute filtering.
Installs: 3 729
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- php: >=7.0.0
- hnhdigital-os/laravel-frontend-asset-loader: ~1.0
- hnhdigital-os/laravel-html-generator: ~1.0
Requires (Dev)
- codeclimate/php-test-reporter: dev-master
- illuminate/database: 4.*|5.*
- phpunit/phpunit: 4.*
- symfony/process: ~2.3
README
Provides the ability to set filtering attributes and model relationship filtering.
This package has been developed by H&H|Digital, an Australian botique developer. Visit us at hnh.digital.
Install
Via composer:
$ composer require hnhdigital-os/laravel-model-filter ~1.0
Usage
use HnhDigital\LaravelModelFilter\Traits\ModelTrait; class User extends Model { use ModelTrait; /** * A nice name for the model. * * @var array */ protected $filter_name = 'User'; /** * A list of relationships for this model. * * @var array */ protected $filter_relationships = [ 'Organization' => 'App\Models\Organization' ]; /** * A list of attributes that can be used for the advanced filtering trait. * * @var array */ protected $filter_attributes = [ 'lookup' => [ 'name' => 'Name or email', 'attribute' => ['first_name', 'last_name', 'email', 'organization.name'], 'filter' => 'string', 'search_tab_only' => true, 'with' => 'organization' ], 'first_name' => ['name' => 'First name', 'attribute' => 'first_name', 'filter' => 'string'], 'last_name' => ['name' => 'Last name', 'attribute' => 'last_name', 'filter' => 'string'], 'email' => ['name' => 'Email', 'attribute' => 'email', 'filter' => 'string'], 'is_active' => ['name' => 'Active user', 'attribute' => 'is_active', 'filter' => 'boolean'] ]; }
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.