以前在其他项目中使用过tcg / voyager软件包,到目前为止,我还没有遇到任何问题。
尝试在新项目中安装它会抛出此错误
Call to undefined method Illuminate\Auth\DatabaseUserProvider::getModel()
at C:\xampp\htdocs\laravel\Veachy backs\Veachy (voyager admin)\vendor\tcg\voyager\src\VoyagerServiceProvider.php:101
97| */
98| public function boot(Router $router, Dispatcher $event)
99| {
100| if (config('voyager.user.add_default_role_on_register')) {
> 101| $model = Auth::guard(app('VoyagerGuard'))->getProvider()->getModel();
102| call_user_func($model.'::created', function ($user) use ($model) {
103| if (is_null($user->role_id)) {
104| call_user_func($model.'::findOrFail', $user->id)
105| ->setRole(config('voyager.user.default_role'))
1 C:\xampp\htdocs\laravel\Veachy backs\Veachy (voyager admin)\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:37
TCG\Voyager\VoyagerServiceProvider::boot(Object(Illuminate\Routing\Router), Object(Illuminate\Events\Dispatcher))
2 C:\xampp\htdocs\laravel\Veachy backs\Veachy (voyager admin)\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:37
call_user_func_array()
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
在下一个php artisan命令中,此错误将普遍存在,直到我删除软件包为止。
在发生此错误之前,我需要将作曲家的内存从512M更新到2G。不知道是否相关。
在安装软件包之前已经更新了作曲家。
版本信息
Laravel:v 7.22.4
PHP:7.3.12
谢谢,
费尔南多
答案 0 :(得分:0)
我遇到了同样的问题,因为我的项目使用“ api”作为默认防护,而不是 'web'(config \ auth.php):
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password
| reset options for your application. You may change these defaults
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => 'api',
'passwords' => 'users',
],
解决方法是将“ app \ Providers \ AppServiceProvider.php”中的“ VoyageGuard”设置为您选择的防护(网络):
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
$this->app->singleton('VoyagerGuard', function () {
return 'web';
});
}
现在,旅行者号将使用网络防护而不是API防护。
最诚挚的问候