entrust
entrust copied to clipboard
Class name must be a valid object or a string
i use below code for remove one record from roles table:
if ( $role = Role::find($id)) {
$role->delete();
return response()->json(['status' => 'success', 'message' => 'operation was successful.']);
}
but, an error happen and the message is:
Class name must be a valid object or a string
i google it!, for some answer i had to say config/entrust.php file exist.
i solved this problem by use Role::whereId($id)->delete();
I am currently experiencing the same problem.
In the EntrustRoleTrait, there is a Config call like this:
Config::get('auth.model')
and the install documentation is not setting this parameter unless I don't understand it. So it's null
.
The documentation sets auth.providers.users.model setting .
I dont think it's coincidence, now in the dev-master there is exactly
Config::get('auth.providers.users.model')
I'll check to switch to dev-master.
I'm rather new to Laravel and while trying to follow the instructions for setting up entrust, I cannot run the entrust:migration command without receiving this same error. Am I doing something wrong with the way I set up my config/auth.php perhaps?
'providers' => [ 'users' => [ 'driver' => 'eloquent', 'model' => App\User::class, 'table' => 'users', ],
Any help would be immensely appreciated!
@andrewelkins I also hit this Error. Please upload the new style in master.
Add this method in Role model
dont forget to get Config Class: use Illuminate\Support\Facades\Config; 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'));
}
god bless you man :)
use this code YourModle::whereId($id)->delete();
Add this in your config/auth.php
'model' => \App\User::class,