Skip to content
Icon

WARNING You're browsing the documentation for an upcoming version of Laravel DataTables. The documentation and features of this release are subject to change.

Black Listing Columns

The blacklist feature allows you to explicitly disable sorting and searching on specific columns. Columns defined in the blacklist will be excluded from sorting and searching operations.


Basic Usage

use Yajra\DataTables\Facades\DataTables;
use App\Models\User;
 
Route::get('user-data', function() {
$model = User::query();
 
return DataTables::eloquent($model)
->blacklist(['password', 'name'])
->toJson();
});

Common Use Cases

Exclude Sensitive Data

return DataTables::eloquent(User::query())
->blacklist(['password', 'api_token', 'remember_token'])
->toJson();

Exclude Action Columns

return DataTables::eloquent(User::query())
->blacklist(['action', 'edit', 'delete'])
->toJson();

See Also