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

@zocios you're using lists() which returns an array. You cannot access an array with -> notation, nor how you are trying to access it here. Your structure will return looking like ['Pittsburgh' => 1, 'Atlanta' =>2]. When in doubt, use dd($var) on your code to check your values when you don't think they are what they should be.

Last updated 2 years ago.
0

Thanks, machuga. I actually discovered an even more basic error which was that I had accidentally labelled the class for the cities table as "city", rather than "cities". So, of course, the class was not recognized, and therefore the attempt to use the class resulted in a non-object, with or without the use of lists(). Once I fixed the class name in Models, the error went away :)

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

zocios zocios Joined 28 May 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.