either hide the field in your model or use select to get just the fields you need
Apr 16, 2017
5
Level 1
the correct way to use makeHidden in laravel
Hi , I have problem with the pagination .
everything work fine without error but the problem is when i use makeHidden with my code it change the structure of my json pagination result
this is my code .
$result = Job::where('user_id','=',Auth::id())->paginate(5);
$result= $result->makeHidden(['hasMessage']);
without the second line the result is
{
total: 1 ,
per_page: 5,
current_page: 1,
last_page: 1,
next_page_url: null,
prev_page_url: null,
from: 1,
to: 1,
data: [
{
id: 4,
sid:125,
hasMessage: true
}
]
}
but when i use
$result= $result->makeHidden(['hasMessage']);
I got
[
{
id: 4,
sid:125,
}
]
any idea please ? ? ? is it a bug or there is something wrong ? ?
Please or to participate in this conversation.