在 null 上调用成员函数 Manages()
P粉818306280
P粉818306280 2023-08-26 14:11:08
[PHP讨论组]

资源/视图/布局/navigation.blade.php: 8需要

在我的主页 Laravel

<!-- 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>

和我的布局导航

我在这一行有错误:@if (auth()->user()->manages())

在 null 上调用成员函数 Manages()

扩展供应商框架资源/视图/布局/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中文网订阅号
每天精选资源文章推送

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