I think it is something like this,
$this->data['item'] = Album::where('album_id', '=', $id)->where('user_id','=',Auth::user()->user_id)->with("photo")->with("photo.tags")->first();
Hello.
TerrePorter shows how to eager load the needed data, use that approach. To show it in the view make something like
<h2>Album {{$album->name}}</h2>
@foreach($album->photo as $photo)
<div>
<img src="{{$photo->url}}"/>
Tags:
@foreach($photo->tags as $tag)
{{$tag->name}}
@endforeach
</div>
@endforeach
$photo->tags is a collection (not array). You have to foreach it to access each element.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.