
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
- Get content from web URL in laravel
- Create model with migration and seeder
- Update email with unique validation in laravel
- How to prevent host header attack in Laravel
- SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint
- Insert values in pivot table dynamically in laravel
- Define variable and use in Laravel controller method
- How to get random string in Laravel
- How to change default timestamp fields name in Laravel
- Laravel hasmany select not working
- Display message with session flash using bootstrap alert class in laravel
- How to get user information using hootlex/laravel-friendships package in laravel
- Create project table with model and migration
- How to get last record from object collection in laravel
- How to add a key value pair to existing array in laravel
- Laravel pagination links with query string
- SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel8.projects' doesn't exist
- How to get path from current URL in Laravel
- How to use bootstrap pagination in laravel 8
- How to get CSRF token in laravel controller
- Insert current date time in a column using Laravel
- Method Illuminate\Database\Eloquent\Collection::lists does not exist
- Order by multiple columns in Laravel
- How to display 1 day ago in comments in laravel view
- Method chaining in Laravel