user() !== null; } protected function prepareForValidation(): void { if ($this->has('key')) { $this->merge([ 'key' => strtoupper((string) $this->string('key')->trim()), ]); } } /** * Get the validation rules that apply to the request. * * @return array|string> */ public function rules(): array { return [ 'key' => [ 'required', 'string', 'max:5', 'regex:/^[A-Z0-9]+$/', Rule::unique('projects', 'key'), ], 'name' => ['required', 'string', 'max:255'], ]; } }