在 null 上呼叫成員函數 Manages()
P粉818306280
P粉818306280 2023-08-26 14:11:08
0
1
473
<p>資源/視圖/佈局/navigation.blade.php: 8需要</p> <p>在我的首頁 Laravel</p> <pre class="brush:php;toolbar:false;"><!-- resources/views/page.blade.php --> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Front Page</title> </head> <body> <!-- Include the navigation menu --> @include('layouts.navigation') <!-- Your front page content goes here --> <h1>Welcome to the front page</h1> <p>This is the content of your front page.</p> </body> </html></pre> <p>和我的佈局導航</p> <p>我在這一行有錯誤:@if (auth()->user()->manages())</p> <p>在 null 上呼叫成員函數 Manages()</p> <p>擴展供應商框架資源/視圖/佈局/navigation.blade.php: 8需要9個供應商框架資源/視圖/welcome.blade.php: 10需要56個供應商框架public/index.php: 51 require_once 1個供應商架構< /p>
P粉818306280
P粉818306280

全部回覆(1)
P粉115840076

這表示您沒有經過身份驗證的用戶,因此首先檢查 auth()->user() 是否存在,例如:

@if (!is_null(auth()->user())) //if auth()->user() is not null, you can call the manages() function on it
     @if(auth()->user()->manages())
       //content you want
     @endif
  @endif
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!