Hi,
If it hasOne('Hour'), why should it be an array ?
Yea, thought it would be the relationships.. Its messed up inside my head right now :D.
I want to output the all of the opening to closing hours of each shop, so I guess it should be many to many then?
One shop has "one" opening hours, so it is hasOne
But you don't have to loop over the hours, as it is just a row object. You can just do it: $listing->hours()->open_mon
I tried doing in my view:
{{ $listing->hours()->open_mon }} - {{ $listing->hours()->close_mon }}
{{ $listing->hours()->open_tue }} - {{ $listing->hours()->close_tue }}
But I get this:
Undefined property: Illuminate\Database\Eloquent\Relations\HasOne::$open_mon
In my show view i can loop over the relationship like this:
{{ $listing->hours->open_mon }} - {{ $listing->hours->close_mon }}
{{ $listing->hours->open_tue }} - {{ $listing->hours->close_tue }}
So im thinking there should be a way?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.