I've following code:
<div class="col-8
offset-2
mb-5
p-3
rounded-lg
shadow
d-flex
justify-content-between
align-items-baseline"
style="background-color: lightgrey;
background-image: linear-gradient(to right, rgba(211, 211, 211, 0.52), rgba(211, 211, 211, 0.73)), url('/images/social_{{$gallery->photos->first()}}'); ">
the part of the code $gallery->photos->first() returns:
{"id":3,"gallery_id":1,"filename":"IMG_3700.png","filesize":4229181,"delete":0,"created_at":"2020-03-28T09:56:31.000000Z","updated_at":"2020-03-28T09:56:31.000000Z"}
I need to access the filename.. I tried a few things, but none of them worked:
$gallery->photos->first('filename')
$gallery->photos->first()->get('filename')
$gallery->photos->first()['filename']
$gallery->photos->first()->filename
the last attempt ($gallery->photos->first()->filename) returned this error:
Facade\Ignition\Exceptions\ViewException Trying to get property 'filename' of non-object (View: C:\xampp\htdocs\galshare\resources\views\home.blade.php)
how can I access the returned filename?
Thanks
$gallery->photos->first()->filenamereturns? this was supposed to workFacade\Ignition\Exceptions\ViewException Trying to get property 'filename' of non-object (View: C:\xampp\htdocs\galshare\resources\views\home.blade.php)$filename = null; if ($gallery && !empty($gallery->photos)) {$photo = $gallery->photos->first(); $filename = $photo->filename;}This has to work regarding first line of your shown code......social/social_{{$gallery->photos->first()}}');