【问题标题】:Laravel and MongoDB gives error Call to a member function prepare() on nullLaravel 和 MongoDB 在 null 上对成员函数 prepare() 给出错误调用
【发布时间】:2019-08-31 13:55:45
【问题描述】:

我试图访问该网页,但我收到了对成员函数 prepare() 的调用。 我应该怎么做? 我正在使用 laravel 和 MongoDB。 所有代码都运行良好,但是当我将 Laravel 从 5.8 更新到 6 时出现上述错误

<!-- Authentication Links --> @guest <li class="nav-item"> <a class="nav-link" href="{{ route('login') }}">{{ __('Login') }}</a> </li> @if (Route::has('register')) <li class="nav-item"> <a class="nav-link" href="{{ route('register') }}">{{ __('Register') }}</a> </li> @endif @else <li class="nav-item dropdown"> <a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre> {{ Auth::user()->name }} <span class="caret"></span> </a> <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown"> <a class="dropdown-item" href="{{ route('logout') }}" onclick="event.preventDefault(); document.getElementById('logout-form').submit();"> {{ __('Logout') }} </a> <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;"> @csrf </form> </div> </li> @endguest

问题是关于@guest

【问题讨论】:

标签: laravel mongodb


【解决方案1】:

在“供应商\laravel\framework\src\Illuminate\Foundation\Auth\User.php”中

添加“使用 Jenssegers\Mongodb\Eloquent\Model 作为 Eloquent;”

将“类用户扩展模型实现”更改为“类用户扩展 Eloquent 实现”

【讨论】:

    【解决方案2】:

    在每个模型中使用添加: “使用 Jenssegers\Mongodb\Eloquent\Model 作为 Eloquent;” 然后你应该从这个雄辩的扩展而不是扩展模型

    【讨论】:

      猜你喜欢
      • 2021-12-22
      • 2019-07-29
      • 2019-04-19
      • 2020-03-11
      • 2018-01-12
      • 2016-09-11
      • 1970-01-01
      相关资源
      最近更新 更多