@foreach($users as $user)
{{ $user->name }}
@endforeach
is there any chance that i can get the data w/out looping?
jrsalunga said:
is there any chance that i can get the data w/out looping?
You can access data object via array index.
{{ $users[0]->name }}
but why?
check with
{{ dd($users) }}
what $users is
you can also check with
{{ get_class_methods($users) }}
what your options are ;)
my users data is like this when i use this
$users->toJson()
i get this
{
"total":2,
"per_page":10,
"current_page":1,
"last_page":1,
"from":1,"to":10,
"data":[
{"username":"jeff","id":"007D5CBEFF31EE645AFD41529FC42561"},
{"username":"jrsalunga","id":"12ab052cb0a811e3a0ecc0188508f93c"}
]
}
with that i want to get the "data" only
Try (Tested on Laravel 5.3)
$users->items()
victorcasajuanamas liked this reply
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community