Search code examples
laravelimagesrcavatar

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}}">

Solution

  • 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) }}">