Quickly filter data by concatenating query strings
composer install imzeali/filter-eloquent
' ' // equal to
'eq' // equal to
'ne' // not equal to
'gt' // Is greater than
'ge' // great than and equal to
'lt' // less than
'le' // less than and equal to
'like' // LIKE
'in' // IN
'not_in' // NOT IN
$q syntax:{field name}__{operator}={query condition}
$q can be spliced by the client
Basis query:
$q = 'id__eq=100';
new Filter(new User(), $q)->filteredQuery();
//Equivalent to
User::where('id',1);
Multiple query conditions:
$q = 'id__gt=100,name__like=%baby%';
new Filter(new User(), $q)->filteredQuery();
//Equivalent to
User::where('id', ‘>’, ‘100’)->where('name','like','%baby%');
Model query conditions
$q = 'user.city__eq=Fuzhou';
new Filter(new Article(), $q)->filteredQuery();
//Equivalent to
Article::whereHas('user', function ($query){
$query->where('city', '=', 'Fuzhou');
});