How to display user profile after login in laravel

You can display user profile after login in laravel. You can get the user details using the Auth::user() helper function which you can call in the blade file.

Answers 1
  • Display user details in view file after login

    --PATH resources\views\<home>.blade.php
    //Display name of authenticated user
    {{ Auth::user()->name }}
    //Get logged in user id
    {{ Auth::user()->id  }} 
    //Display logged in user image
    @if( isset(Auth::user()->image) && file_exists('storage/'.Auth::user()->image))
        <img src="{{ asset('storage/'.Auth::user()->image) }}" alt="{{ Auth::user()->image }}">
        <img src="{{ asset('frontend/images/imagenotfound.jpg') }}" alt="...">

    Auth::user() will work only if the user is authenticated/logged in else it will give an error.  To display the image you have to link the storage folder and check if the file exists in  /storage/{user_profile}.jpg and display using asset method.

  • Back to code snippet queries related laravel