search

Home  >  Q&A  >  body text

Calling member function Manages() on null

<p>resources/views/layout/navigation.blade.php: 8 required</p> <p>On my homepage 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>And my layout navigation</p> <p>I have an error in this line: @if (auth()->user()->manages())</p> <p>Call member function Manages() on null</p> <p>Extended vendor framework resources/views/layout/navigation.blade.php: 8 requires 9 vendor frames resource/view/welcome.blade.php: 10 requires 56 vendor frames public/index.php: 51 require_once 1 supplier framework< /p>
P粉818306280P粉818306280445 days ago495

reply all(1)I'll reply

  • P粉115840076

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

    This means you don't have an authenticated user, so first check if auth()->user() exists, for example:

    @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

    reply
    0
  • Cancelreply