entrust: Class name must be a valid object or a string
php artisan entrust:migration
[Symfony\Component\Debug\Exception\FatalErrorException] Class name must be a valid object or a string
in config/auth.php
add:
'model' => 'App\Models\User', 'table' => 'users',
Then created User Model:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Zizaco\Entrust\Traits\EntrustUserTrait;
class User extends Model
{
use EntrustUserTrait; // add this trait to your user model
}
That’s OK!
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 16 (1 by maintainers)
Try to change EntrustRoleTrait line 51 to
I got same issue with Laravel 5.2. To resolve Locate
./vendor/zizaco/entrust/src/commands/MigrationCommand.php
and change code (Line number 84 and 85) from:To:
PS. Remember to Run command
composer dump-autoload
after performing changes.Thanks.
add line config/auth.php
Good luck 😃
Adding a users method in Role model solved the issue for me public function users() { return $this->belongsToMany(Config::get(‘auth.providers.users.model’),Config::get(‘entrust.role_user_table’),Config::get(‘entrust.role_foreign_key’),Config::get(‘entrust.user_foreign_key’));
}
Thank tanteng!!!
Adding: ‘model’ => ‘App\User’, ‘table’ => ‘users’,
to the auth.php did the trick
I had to change line 86 and 87 of MigrationCommand to: config(‘auth.table’); config(‘auth.model’);
And that got it working
Applied the solution @jameskandau provided, it solved the issue in Laravel 5.4.28.
I just removed Entrust and replaced it with @santigarcor 's package. Solved my issues.
You could use this fork a friend of mine and i are mantaining. we have solved a lot of problems of this package