has('new_email')) { $this->merge([ 'new_email' => strtolower(trim((string) $this->input('new_email'))), ]); } } public function rules(): array { return [ 'new_email' => [ 'required', 'string', 'lowercase', 'email', 'max:255', Rule::unique(User::class, 'email')->ignore((int) $this->user()->id), function (string $attribute, mixed $value, \Closure $fail): void { if (strtolower((string) $value) === strtolower((string) $this->user()->email)) { $fail('Please enter a different email address.'); } }, ], ]; } }