首頁  >  問答  >  主體

在 null 上呼叫成員函數 Manages()

<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粉818306280P粉818306280392 天前457

全部回覆(1)我來回復

  • P粉115840076

    P粉1158400762023-08-27 09:32:07

    這表示您沒有經過身份驗證的用戶,因此首先檢查 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

    回覆
    0
  • 取消回覆