Search code examples
laravelentrust

issue in deleting role in Zizaco/entrust


Iam trying to delete a role

$role = Role::findOrFail(1);
$role->delete();

I got the following error

FatalErrorException in Model.php line 945:
Class name must be a valid object or a string

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

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

Role model class

namespace App\Models;

use Zizaco\Entrust\EntrustRole;

class Role extends EntrustRole
{
       protected $fillable =  ['name', 'display_name', 'isActive','description', 'created_at', 'updated_at'];

}

Solution

  • I think this is the problem:

    Find the file: vendor/zizaco/entrust/src/Entrust/Traits/EntrustRoleTrait.php

    Replace

    Line 51: ... Config::get('auth.model') ...

    with

    Line 51: ... Config::get('auth.providers.users.model') ...