Laravel - Property [name] does not exist on this collection instance -


i trying create collection , pass blade. php code this

$collection1 = collect(['name' => 'alex', 'id' => '1']); $collection2 = collect(['name' => 'john', 'id' => '2']); $collection3 = collect(['name' => 'andy', 'id' => '3']);  $people_col = new collection();  $people_col->push($collection1); $people_col->push($collection2); $people_col->push($collection3);  return view('test',[     'people_col' => $people_col ]); 

in blade loop through people_col properties of items:

 @foreach ($people_col $people)         <tr>              <td>{{ $people->name }}</td>             <td>{{ $people->id }}</td>                        </tr>  @endforeach 

however got error:

property [name] not exist on collection instance

any idea? thanks

try access property name way: $people['name']

@foreach ($people_col $people)         <tr>              <td>{{ $people['name'] }}</td>             <td>{{ $people['id'] }}</td>                        </tr>  @endforeach 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -