如何修复laravel 5.2中的zizaco委托:迁移类名验证



我在GitHub Link上学习了zizac/truste安装教程,遇到了错误:

类名必须是中的有效对象或字符串var/www/html/laravel_test/vender/zizaco/contruste/src/commands/MigrationCommand.php在线86

MigrationCommand.php文件url:Link

输出:

php artisan entrust:migration
Tables: roles, role_user, permissions, permission_role
A migration that creates 'roles', 'role_user', 'permissions', 'permission_role' tables will be created in database/migrations directory
Proceed with the migration creation? [Yes|no] (yes/no) [yes]: yes
Creating migration...
PHP Fatal error:  Class name must be a valid object or a string in /var/www/html/laravel_test/vendor/zizaco/entrust/src/commands/MigrationCommand.php on line 86

命令:php artisan vendor:publish成功。

文件:config/entrust.php存在。

我没有像-auth.php一样更改config/auth.php文件的任何选项。如何修复它?

在vendor/zizaco/contrust/src/concommands/MigrationCommand.php中,第86行

删除行:

    $usersTable  = Config::get('auth.table');
    $userModel   = Config::get('auth.model');

添加行:

$usersTable  = Config::get('auth.providers.users.table');
$userModel   = Config::get('auth.providers.users.model');

和config/auth.php文件写入提供程序行一样:

'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => AppUser::class,
        'table' => 'users',
    ],
    // 'users' => [
    //     'driver' => 'database',
    //     'table' => 'users',
    // ],
],

那么你的问题就解决了:愉快地编码

在vendor/zizaco/contruste/src/commands/MigrationCommand.php中的第86行。

Laravel 5.1.*添加行

$usersTable  = Config::get('auth.table');
$userModel   = Config::get('auth.model');

Laravel 5.2.*添加行

$usersTable  = Config::get('auth.providers.users.table');
$userModel   = Config::get('auth.providers.users.model');

接受的答案可能会解决问题,但编辑直接供应商文件是非常糟糕的做法。以下内容将解决您可能遇到的问题,并将支持您的应用程序在您决定更新Entrust并修复其代码库时仍能正常工作。

config/auth.php下面添加以下行:

/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/

Laravel 5.1-5.4

'model' => AppModelsUser::class,
'table' => 'users',

一旦Entrust推出更新,您可以删除或保留它。由您决定。

尝试运行:

php artisan config:cache

以确保您的应用程序正在使用新的配置文件

编辑

好的,现在我明白了,这个库想要使用:

  $usersTable  = Config::get('auth.table');
  $userModel   = Config::get('auth.model');

但是在CCD_ 1中不再存在类似的东西。

因此,作为临时解决方案,您应该先将tablemodel添加到auth文件中,如下所示:https://github.com/laravel/laravel/blob/5.1/config/auth.php

并等待Entrust将被升级以删除此

相关内容

  • 没有找到相关文章

最新更新