Skip to content

Latest commit

 

History

History
17 lines (12 loc) · 588 Bytes

make-hidden.md

File metadata and controls

17 lines (12 loc) · 588 Bytes

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