Skip to content

WARNING You're browsing the documentation for an old version of LARAVEL-DATATABLES. Consider upgrading your project to laravel-datatables 10.0.

Filter Column

In some cases, we need to implement a custom search for a specific column. To achieve this, you can use filterColumn api.

use Datatables;
use DB;
Route::get('user-data', function() {
$model = App\User::select([
DB::raw("CONCAT(users.first_name,'-',users.last_name) as fullname"),
return Datatables::eloquent($model)
->filterColumn('fullname', function($query, $keyword) {
$sql = "CONCAT(users.first_name,'-',users.last_name) like ?";
$query->whereRaw($sql, ["%{$keyword}%"]);