Search code examples
phplaravelauthenticationhreflaravel-6

Setting URL with logged in user id from the front end blade in LARAVEL 6


Hello I'm trying to set an URL (href) from my blade(welcome.blade.php) to logged in user's user profile.

My url has to be like this -> sample.com/profile/24

there, 24 is logged in user's user id

<a href="{{URL('/profile/{{ Auth::user()->id }}')}}" class="btn btn-primary">profile</a>

but when I run the code it gives me following exception,

Facade\Ignition\Exceptions\ViewException syntax error, unexpected '}', expecting ')'


Solution

  • There is no need to use {{}} again inside {{}}

    Change

    <a href="{{URL('/profile/{{ Auth::user()->id }}')}}" class="btn btn-primary">profile</a>
    

    to

    <a href="{{URL('/profile/'.Auth::user()->id)}}" class="btn btn-primary">profile</a>