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

What does it return when you do

 return View::make('frontend.agenda.index')->with('dates', $dates);
Last updated 2 years ago.
0

If I do $dates->exhibits->title and your recommendation, then I receive a null or this error "Undefined property: Illuminate\Database\Eloquent\Collection::$id "

If I do $dates->exhibit->title then I receive "Trying to get property of non-object"

Last updated 2 years ago.
0

Does anyone have any thoughts on this? I have spent a few extra hours this morning and I still can't discover my problem.. it seems to follow the OneToMany tutorials around the internet.

Last updated 2 years ago.
0

It's simple, $date->exhibits returns Collection of objects, while you treat it like a single object.

Use

 foreach ($date->exhibits as $exhibit) { $exhibit->id; // or whatever you want from this object }
Last updated 2 years ago.
0

I got it to work the way I wanted it to! But I wanted to see why this worked and not your solution...

I did what you said above and I received the same error as I originally mentioned. But I wanted to create a nested ForEach to show the date (which is $date->title) and then events under that date in another ForEach loop ($exhibits->title). That worked perfectly.

($date->exhibits as $exhibit) and ($dates->exhibits as $exhibit) did not work. How can I combat this in the future?

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Failcookie failcookie Joined 20 Mar 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.