public function update($id, UpdateRoleRequest $request)
    {
        $role = $this->roleRepository->findWithoutFail($id);

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

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

        $input = $request->all();

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

        $permissions = [];

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

        $role->permissions()->sync($permissions);

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

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