Skip to content

Commit e2f0975

Browse files
committed
Make hidden
1 parent 355d1ac commit e2f0975

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Diff for: make-hidden.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Hide attributes from Json
2+
3+
When you are working with Eloquent Object, you can apply the `makeHidden()` ([Laravel documentation](https://laravel.com/docs/master/eloquent-serialization#hiding-attributes-from-json)) function before converting your object toArray().
4+
5+
It can prevent overriding attributes to be compute and increase the performance of converting the object into an array.
6+
7+
```php
8+
use DataTables;
9+
10+
Route::get('user-data', function() {
11+
$model = App\User::with('posts.comment')->query();
12+
13+
return DataTables::eloquent($model)
14+
->makeHidden('posts')
15+
->toJson();
16+
});
17+
```

0 commit comments

Comments
 (0)