> */ public function rules(): array { return [ 'name' => [ 'required', 'string', 'min:1', 'max:255', UniqueEloquent::make(Project::class, 'name', function (Builder $builder): Builder { /** @var Builder $builder */ return $builder->whereBelongsTo($this->organization, 'organization'); })->withCustomTranslation('validation.project_name_already_exists'), ], 'color' => [ 'required', 'string', 'max:255', new ColorRule, ], 'is_billable' => [ 'required', 'boolean', ], 'billable_rate' => [ 'nullable', 'integer', 'min:0', 'max:2147483647', ], // ID of the client 'client_id' => [ 'nullable', ExistsEloquent::make(Client::class, null, function (Builder $builder): Builder { /** @var Builder $builder */ return $builder->whereBelongsTo($this->organization, 'organization'); })->uuid(), ], // Estimated time in seconds 'estimated_time' => [ 'nullable', 'integer', 'min:0', 'max:2147483647', ], // Whether the project is public 'is_public' => [ 'boolean', ], ]; } public function getIsPublic(): bool { return $this->has('is_public') && $this->boolean('is_public'); } public function getBillableRate(): ?int { $input = $this->input('billable_rate'); return $input !== null && $input !== 0 ? (int) $this->input('billable_rate') : null; } public function getEstimatedTime(): ?int { $input = $this->input('estimated_time'); return $input !== null && $input !== 0 ? (int) $this->input('estimated_time') : null; } }