简体   繁体   中英

Avatar Not Showing Laravel

I'm working with laravel framework, I have to create a profile so I changed the table User created in the Auth.. all works perfectly. I also added a Picture for the Profile picture or Avatar in the User table.

I made a profile page Image are showing and even to my nav bar.

this is the code I used.. and it work in other pages.

 <img src="img/avatar/{{Auth::user()->picture}}">

this one is for my logo image I put the {{URL::asset}} because it's not showing also in another pages

 <img src="{{ URL::asset('img/weblogo.png') }}">

then it works perfectly in all pages

but when I try to use it in the image from my database, It won't work and said

<img src="{{ URL::asset('img/avatar/{{Auth::user()->picture}}') }}">

syntax error, unexpected '}', expecting ')'

in my view

but when I try this, it won't work with all the pages

 <img src="img/avatar/{{Auth::user()->picture}}">

Set asset as below

<img src="{{ asset('img/avatar/'.Auth::user()->picture) }}">

Or if you want to use URL::asset then

<img src="{{ URL::asset('img/avatar/'.Auth::user()->picture) }}">

You don't need to use {{ again inside {{ }}

Change

<img src="{{ URL::asset('img/avatar/{{Auth::user()->picture}}') }}">

to

<img src="{{ URL::asset('img/avatar/'.Auth::user()->picture) }}">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM