route('user')); } /** * Prepare the data for validation. * * @return void */ protected function prepareForValidation(): void { /** @var \App\Models\User $userModel */ $userModel = request()->route()->parameter('user'); /** @var \App\Models\User $authUserModel */ $authUserModel = auth('backend')->user(); $this->merge([ 'published' => $authUserModel->getKey() !== $userModel->getKey() ? $this->boolean('published') : true, 'password' => $this->input('password') ?? \optional($this->route('user'))->password, 'password_confirmation' => $this->input('password_confirmation') ?? \optional($this->route('user'))->password ]); } /** * Get the validation rules that apply to the request. * * @return array */ public function rules(): array { return array_merge(parent::rules(), [ 'email' => [ 'required', 'email:rfc,strict,dns,spoof,filter', Rule::unique('users', 'email')->ignore(\optional($this->route('user'))->getRouteKey()) ], 'password' => [ 'required', 'required_with:password_confirmation', 'confirmed', 'max:255', Password::min(8) ->letters() ->mixedCase() ->numbers() ->symbols() ->uncompromised() ], ]); } }