在 null 上调用成员函数 Manages()
P粉818306280
P粉818306280 2023-08-26 14:11:08
[PHP讨论组]
<p>资源/视图/布局/navigation.blade.php: 8需要</p> <p>在我的主页 Laravel</p> <pre class="brush:php;toolbar:false;">&lt;!-- resources/views/page.blade.php --&gt; &lt;!DOCTYPE html&gt; &lt;html lang=&quot;en&quot;&gt; &lt;head&gt; &lt;meta charset=&quot;UTF-8&quot;&gt; &lt;title&gt;Front Page&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;!-- Include the navigation menu --&gt; @include('layouts.navigation') &lt;!-- Your front page content goes here --&gt; &lt;h1&gt;Welcome to the front page&lt;/h1&gt; &lt;p&gt;This is the content of your front page.&lt;/p&gt; &lt;/body&gt; &lt;/html&gt;</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
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号