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();
});