public function newPivot(Model $parent, array $attributes, $table, $exists)
{
$userModel = app()['config']->get('defender.user_model');
$roleModel = app()['config']->get('defender.role_model');
if ($parent instanceof $userModel) {
return new PermissionUserPivot($parent, $attributes, $table, $exists);
}
if ($parent instanceof $roleModel) {
return new PermissionRolePivot($parent, $attributes, $table, $exists);
}
return parent::newPivot($parent, $attributes, $table, $exists);
}