Aronaman
3 months ago
236
5
Laravel

getFirstMediaUrl() on string

Posted 3 months ago by Aronaman

controller

public function show($slug, $id){
        
        $singleOrganization=Organization::where('slug',$slug)->where('id',$id)->firstOrFail();
        return view('singleOrganization', compact('singleOrganization'));
    }
@foreach ($singleOrg->getMedia('gallary') as $galleryItem)
            <div class="site-blocks-cover" style="background-image: url('{{ $galleryItem->getFullUrl() }}');"
                 data-aos="fade" data-stellar-background-ratio="0.5">
                 @endforeach

singleOrganization.blade

@foreach ($singleOrganization as $singleOrg )
            <div class="site-blocks-cover" style="background-image: url('{{ $singleOrg->getFirstMediaUrl('gallary') }}');"
                 data-aos="fade" data-stellar-background-ratio="0.5">
@endforeach

I try this, but it shows me some error "getFirstMediaUrl() on string"

Please sign in or create an account to participate in this conversation.