App\Services\Form\User\UserForm::updateRole PHP Метод

updateRole() публичный Метод

Update a role of an existing user.
public updateRole ( array $input ) : boolean
$input array Data to update a user
Результат boolean
    public function updateRole(array $input)
    {
        if (!$this->valid($input)) {
            return false;
        }
        if (!isset($input['role'])) {
            $input['role'] = [];
        }
        DB::transaction(function () use($input) {
            $user = $this->user->byId($input['id']);
            $user->revokeAllRoles();
            if (!empty($input['role'])) {
                $user->assignRole($input['role']);
            }
        });
        return true;
    }