2017-07-18 61 views
1

我有這樣的錯誤試圖讓非對象試圖讓非對象錯誤的性質

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

並指出了該行的屬性這一行

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

有什麼我的代碼中有錯誤或錯誤?我在其他頁面的個人資料,這是我的個人資料頁圖像標籤

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

似乎'{{驗證::用戶() - >頭像} }'沒有頭像數據 –

+0

id使用我的個人資料(管理)頁面中的代碼,它的工作原理,但是當我嘗試把我的用戶頁面,它給了我錯誤 –

+0

檢查之前得到Auth屬性'if(Auth :: check()){'您已登錄'; }' – Hari

回答

1

您應經常檢查,如果用戶進行身份驗證:

@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