What does it return when you do
return View::make('frontend.agenda.index')->with('dates', $dates);
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"
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.
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 }
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?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community