Skip to content
Icon

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

Hide attributes from Json

When you are working with Eloquent Object, you can apply the makeHidden() (Laravel documentation) function before converting your object toArray().

It can prevent overriding attributes to be compute and increase the performance of converting the object into an array.

use DataTables;
 
Route::get('user-data', function() {
$model = App\User::with('posts.comment')->query();
 
return DataTables::eloquent($model)
->makeHidden('posts')
->toJson();
});