Skip to content
Icon

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

Edit Column

You can edit a column on your response by using editColumn api.

Edit Column with Blade Syntax

use Datatables;
 
Route::get('user-data', function() {
$model = App\User::query();
 
return Datatables::eloquent($model)
->editColumn('name', 'Hi {{$name}}!')
->make(true);
});

Edit Column with Closure

use Datatables;
 
Route::get('user-data', function() {
$model = App\User::query();
 
return Datatables::eloquent($model)
->editColumn('name', function(User $user) {
return 'Hi ' . $user->name . '!';
})
->make(true);
});

Edit Column with View

{tip} You can use view to render your added column by passing the view path as the second argument on editColumn api.

use Datatables;
 
Route::get('user-data', function() {
$model = App\User::query();
 
return Datatables::eloquent($model)
->editColumn('name', 'users.datatables.into')
->make(true);
});

Then create your view on resources/views/users/datatables/name.blade.php.

Hi {{ $name }}!