entrust: Can't delete Role model since upgrading to Laravel 5.2

The following exception gets thrown when trying to delete a Role model:

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

I believe I have followed the installation instructions to the letter. All I am calling to throw this error is:

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

About this issue

Most upvoted comments

@akramwahid would you be so nice and post the solution for the error?

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

Well, nevermind…

File: EntrustRoleTrait.php

Replace

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

with

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

I had this issue too. Am not confortablen with changes core vendor files. so inside App\Role.php is added `/**

  • Many-to-Many relations with the user model.
  • @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ 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’)); // return $this->belongsToMany(Config::get(‘auth.model’), Config::get(‘entrust.role_user_table’)); } ` This should work.