Support the ongoing development of Laravel.io →
Database Eloquent Views
Last updated 2 years ago.
0

When you use DB('table_name')->get() it returns a Collection that means it is a Class you should use $item->name instead of $item['name']

But if you want keep use array syntax then change this line:

$data['items'] = DB::table('items')->get();

to be:

$data['items'] = DB::table('items')->get()->toArray() // Or ->all();
0

Got it, thanks for the clarification.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Luke Ramus elramus Joined 26 Feb 2018

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.