public function update($id, UpdatePermissionRequest $request)
    {
        $permission = $this->permissionRepository->findWithoutFail($id);

        if (empty($permission)) {
            Flash::error(trans('l5starter::messages.404_not_found'));

            return redirect(route('admin.permissions.index'));
        }

        $input = $request->all();

        $permission = $this->permissionRepository->update([
            'name' => $input['name'],
        ], $id);

        $roles = [];

        if (!empty($input['roles'])) {
            foreach ($input['roles'] as $role) {
                $roles[$role] = $role;
            }
        }

        $permission->roles()->sync($roles);

        Flash::success(trans('l5starter::messages.update.success'));

        return redirect(route('admin.permissions.index'));
    }