Support the ongoing development of Laravel.io →
Database Eloquent Blade
Last updated 2 years ago.
0
@foreach($users as $user)
    {{ $user->name }}
@endforeach
Last updated 2 years ago.
0

is there any chance that i can get the data w/out looping?

Last updated 2 years ago.
0

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?

Last updated 2 years ago.
0

check with

{{ dd($users) }}

what $users is

you can also check with

{{ get_class_methods($users) }}

what your options are ;)

Last updated 2 years ago.
0

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

Last updated 2 years ago.
0

Try

$users->getItems();
Last updated 2 years ago.
0

Try (Tested on Laravel 5.3)

$users->items()

victorcasajuanamas liked this reply

1

Sign in to participate in this thread!

Eventy

Your banner here too?

jrsalunga jrsalunga Joined 25 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.