public function getEmailValidationRule() : string { $uniqueRule = Rule::unique('users_front', 'email'); if ($this->method() === 'PATCH') { $userId = $this->getRouteParameter('member'); $uniqueRule = $uniqueRule->ignore($userId); } return "required|email|{$uniqueRule}"; }
/** * Update the menu. * * @param Menu $menu Menu type * * @return \Illuminate\Http\RedirectResponse */ public function update(Menu $menu) { $this->validate(request(), ['code' => ['required', Rule::unique('menus')->ignore($menu->id)], 'title' => 'required', 'sort_order' => 'required|integer']); if (request()->ajax()) { return ajaxSuccess(); } if ($menu->update(['code' => snake_slug(request()->code), 'title' => ucfirst(request()->title), 'sort_order' => request()->sort_order])) { flash()->success(trans('admin::messages.success'), trans('admin::menus.updated', ['name' => request()->title])); } return redirect()->route('menus.index'); }
/** * Update the role. * * @param Role $role Role * * @return \Illuminate\Http\RedirectResponse */ public function update(Role $role) { $this->validate(request(), ['name' => ['required', Rule::unique('roles')->ignore($role->id)], 'label' => 'required', 'sort_order' => 'required|integer']); if (request()->ajax()) { return ajaxSuccess(); } if ($role->update(['name' => snake_slug(request()->name), 'label' => ucfirst(request()->label), 'sort_order' => request()->sort_order, 'is_admin' => isset(request()->is_admin)])) { flash()->success(trans('admin::messages.success'), trans('admin::roles.updated', ['name' => request()->name])); } return redirect()->back(); }
/** * Update the plugin. * * @param Plugin $plugin Plugin * * @return \Illuminate\Http\RedirectResponse */ public function update(Plugin $plugin) { $this->validate(request(), ['title' => ['required', Rule::unique('plugins')->ignore($plugin->id)], 'action' => 'required', 'sort_order' => 'required|integer']); if (request()->ajax()) { return ajaxSuccess(); } if ($plugin->update(array_merge(request()->all(), ['is_hidden' => isset(request()->is_hidden)]))) { flash()->success(trans('admin::messages.success'), trans('admin::plugins.updated', ['name' => request()->title])); } return redirect()->route('plugins.index'); }
/** * Update the permission. * * @param Permission $permission Permission * * @return \Illuminate\Http\RedirectResponse */ public function update(Permission $permission) { $this->validate(request(), ['name' => ['required', Rule::unique('permissions')->ignore($permission->id)], 'label' => 'required', 'sort_order' => 'required|integer']); if (request()->ajax()) { return ajaxSuccess(); } if ($permission->update(['name' => snake_slug(request()->name), 'label' => ucfirst(request()->label), 'sort_order' => request()->sort_order])) { flash()->success(trans('admin::messages.success'), trans('admin::permissions.updated', ['name' => request()->name])); } return redirect()->route('permissions.index'); }
/** * Update the codelist item. * * @param CodelistItem $item Codelist item * * @return \Illuminate\Http\RedirectResponse */ public function updateItem(CodelistItem $item) { $this->validate(request(), ['code' => ['required', Rule::unique('codelist_item')->where(function ($query) use($item) { $query->where('codelist_group_id', $item->codelist_group_id); })], 'title' => 'required', 'sort_order' => 'required|integer']); if (request()->ajax()) { return ajaxSuccess(); } if ($item->update(request()->all())) { flash()->success(trans('admin::messages.success'), trans('admin::codelist.item_updated', ['name' => request()->title])); } return redirect()->back(); }
/** * Get the validation rules that apply to the request. * * @return array */ public function rules() { return ['name' => 'required|max:255', 'email' => ['required', 'email', 'max:255', Rule::unique('users')], 'password' => 'required|min:6|confirmed']; }