How to fix in laravel 5.2 zizaco entrust:migration class name validation?

喜你入骨 提交于 2019-12-03 03:24:18

in vendor/zizaco/entrust/src/commands/MigrationCommand.php on line 86

remove line :

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

add line :

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

and config/auth.php file write provider line as like me :

'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\User::class,
        'table' => 'users',
    ],

    // 'users' => [
    //     'driver' => 'database',
    //     'table' => 'users',
    // ],
],

then your problem will solve : happy coding

sebahattin çatal

In vendor/zizaco/entrust/src/commands/MigrationCommand.php on line 86.

Laravel 5.1.* Add Line

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

Laravel 5.2.* Add Line

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

The accepted answer may fix the problem but it is very bad practice to edit direct vendor files. The following will fix the issue you may be having and will support your app still working if you decide to update Entrust and they fix their codebase.

Add the following lines to config/auth.php underneath:

/*
|--------------------------------------------------------------------------
| 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' => \App\Models\User::class,
'table' => 'users',

Once Entrust rolls out an update you can remove this or keep it. Up to you.

Try running:

php artisan config:cache

to make sure your application is using fresh config files

EDIT

Ok, now I see, this library want to use:

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

but there is no something like this in auth any more.

So as temporary workaround you should probaby add table and model to auth file like so: https://github.com/laravel/laravel/blob/5.1/config/auth.php

and wait until Entrust will be upgraded to remove this

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!