How to display user profile after login in laravel

Created at 22-Sep-2021 , By samar

How to display user profile after login in laravel

In this tutorial, we will try to find the solution to "How to display user profile after login in laravel" through programming.

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.
  • 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

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

Don't forget to share this article! Help us spread the word by clicking the share button below.

We appreciate your support and are committed to providing you valuable and informative content.

We are thankful for your never ending support.