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.
delete() method dos not work on Role Model, in this situation for delete one record or one role after find for exp Role::whereId($id)->delete(); work for me and my problem solved for no.
Add this method in Role model:
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')
);
}