How to display user profile after login in laravel
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 }}"> @else <img src="{{ asset('frontend/images/imagenotfound.jpg') }}" alt="..."> @endif
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.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
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.
Random Code Snippet Queries: Laravel
- Laravel file size validation not working
- Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.0"
- How to make Copy or Duplicate table row in laravel
- SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel8.projects' doesn't exist
- If condition in Laravel 9
- Recursive function example code PHP Laravel
- Page loader in laravel
- How to validate form input data in laravel
- Laravel upload file with original file name
- After image selected get validation error in laravel
- Laravel create default admin user
- How to insert dynamic value to additional column in pivot table in laravel
- How to authenticate admin users in Laravel ?
- How to run a specific seeder class in laravel
- How to generate .env file for laravel?
- Use withCount() to Calculate Child Relationship Records
- Retrieve count of nested relationship data in Laravel
- Laravel 9 pagination with search filter
- Get comma separated email from input array
- Display success message in laravel
- Undefined property: stdClass::$title
- Get the post details if it has at least one comment in comments table
- How to get tomorrow and yesterday date in laravel
- How to add dynamic page title in Laravel view
- How to call controller function from view in Laravel