Kurt Pino
Kurt Pino

Reputation: 73

Trying to get property of non-object Error

I have this error Trying to get property of non-object

(View: C:\xampp\htdocs\DigitalStudio\resources\views\welcome.blade.php)
in b1747510b3c408d907ba1958669ebd058ad57227.php (line 101)

and the line that pointed out is this line

<img src="/uploads/avatars/{{ Auth::User()->avatar }}" class="img-circle person" alt="Random Name" width="255" height="255">

is there any wrong or mistake in my code ? in my other page profile and this is my profile page image tag

 <img src="/uploads/avatars/{{ Auth::User()->avatar }}" style="width:150px; height:150px; float:left; border-radius:50%; margin-right:25px;">

Upvotes: 1

Views: 375

Answers (1)

Alexey Mezenin
Alexey Mezenin

Reputation: 163768

You should always check if a user is authenticated:

@if (auth()->check())
    <img src="/uploads/avatars/{{ auth()->user()->avatar }}" style="width:150px; height:150px; float:left; border-radius:50%; margin-right:25px;">
@else
    Please login
@endif

Upvotes: 1

Related Questions