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
- Touch parent updated_at in Laravel
- How to display serial number in Laravel?
- Remove public from url in laravel project
- Pass variable from blade to controller Laravel
- Validation for multiple forms on same page in laravel
- Command to create MySQL Docker image and access the MySQL command-line interface (CLI) within a running Docker container
- Laravel 11 step by step instructions to upload file in storage directory and display in blade file
- How to authenticate admin users in Laravel ?
- Get last year created records in Laravel
- Link storage folder in laravel 8
- The Pusher library requires the PHP cURL module. Please ensure it is installed
- How to create static page in Laravel
- Convert input array to comma-separated string in laravel controller
- How to check duplicate entry in laravel
- How to validate website url in laravel using validaiton
- How to get last record from object collection in laravel
- Laravel 5.4 save data to database
- How to create controller in laravel
- Laravel form request validation
- Syntax error or access violation: 1072 Key column 'role_id' doesn't exist in table (SQL: alter table `users` add constraint `users_role_id_foreign` foreign key (`role_id`) references `roles` (`id`))
- Remove several global scope from query
- Create user in Laravel using tinker
- Method Illuminate\Events\Dispatcher::fire does not exist
- Update if exist else insert new record in laravel
- Ajax GET request in laravel