mohammadabusultan / laravel-filter
A Laravel package for adding filter functionality to models.
dev-master
2023-07-04 14:55 UTC
Requires
- php: ^8.0
- illuminate/database: *
- illuminate/support: *
This package is auto-updated.
Last update: 2024-12-04 17:53:30 UTC
README
A laravel package to filter via your models .
installation :
composer require mohammadabusultan/laravel-filter
Usage :
- use
Filterable
trait in your model - Define
$filters
array property in your model to select which columns to filter in
Example :
use Mohammadabusultan\LaravelFilter\Filterable;
class User extends Model {
use Filterable ;
protected $filters = ['name' => 'like', 'status' => '=', 'posts.title' => 'like'];
public function posts(){
return $this->hasMany(Post::class);
}