
Attempt to read property "avatar" on null in Laravel
Created at 08-Mar-2022 ,
By samar
Attempt to read property "avatar" on null in Laravel
Good day, guys. In this post, we’ll look at how to solve the "Attempt to read property "avatar" on null in Laravel" programming puzzle.
Error Attempt to read property "avatar" on null occurs when you to try to display the user avatar and $user->avatar returns null while displaying user information in blade file.-
Display user avatar with condition in Laravel blade
<img src="{{ $user->avatar !== null ? asset($user->avatar) : asset('/') }}" alt=".."/> //Controller Code. $user = User::query()->where('id','=', $id)->first(); return view('user.profile', compact('user'));
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 order by date not working
- How to print form data in laravel
- Return redirect laravel not working
- Print last executed query in laravel
- Laravel insert query not working
- How to get specific columns using Laravel eloquent methods
- How to display validation error in laravel
- Cast Array to an Object in Controller and then pass to view in laravel
- SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key
- Call to undefined function Illuminate\Encryption\openssl_cipher_iv_length()
- Touch parent updated_at in Laravel
- How to pass two variables in HREF in laravel
- Send post data from controller to view
- Laravel recursive function in controller
- Get comma separated email from input array
- How to get user information using hootlex/laravel-friendships package in laravel
- Credit card validation in laravel
- Link storage folder in laravel 8
- How to pass query string with pagination in laravel
- Extra Filter Query on Relationships in Laravel
- How to disable timestamps in laravel
- Skip first n record and display rest records in laravel view
- Array to string conversion laravel Controller
- How to make Copy or Duplicate table row in laravel
- How to check email is valid or not in Laravel