You can optionally write your own manual filtering functions and thus disabling global search of the package.
To achieve this, you can use the filter
api.
use Datatables;
Route::get('user-data', function() {
$model = App\User::query();
return Datatables::eloquent($model)
->filter(function ($query) {
if (request()->has('name')) {
$query->where('name', 'like', "%{request('name')}%");
}
if (request()->has('email')) {
$query->where('email', 'like', "%{request('email')}%");
}
})
->make(true);
});
{tip} To enable global search with filter api, just set the 2nd argument to
true
.
use Datatables;
Route::get('user-data', function() {
$model = App\User::query();
return Datatables::eloquent($model)
->filter(function ($query) {
if (request()->has('name')) {
$query->where('name', 'like', "%{request('name')}%");
}
if (request()->has('email')) {
$query->where('email', 'like', "%{request('email')}%");
}
}, true)
->make(true);
});