user()?->can('create-project') ?? false; } protected function prepareForValidation(): void { $key = Arr::get($this->all(), 'key'); if ($key !== null) { $this->merge([ 'key' => strtoupper(trim((string) $key)), ]); } } /** * 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'], ]; } }