*/ public function rules(): array { $technology = $this->route('technology'); $creating = ! $technology instanceof Technology; $sometimes = $creating ? 'required' : 'sometimes'; return [ 'name' => [$sometimes, 'string', 'max:120'], 'slug' => [ $sometimes, 'string', 'max:120', 'alpha_dash:ascii', Rule::unique('technologies', 'slug')->ignore($technology?->id), ], 'description' => ['sometimes', 'nullable', new Translatable(max: 1000)], 'radar_note' => ['sometimes', 'nullable', new Translatable(max: 1000)], 'category' => ['sometimes', Rule::enum(TechnologyCategory::class)], // Null keeps it off the radar while projects can still be tagged with it. 'radar_ring' => ['sometimes', 'nullable', Rule::enum(RadarRing::class)], 'color' => ['sometimes', 'nullable', 'string', 'regex:/^#[0-9a-fA-F]{6}$/'], 'logo' => ['sometimes', 'nullable', 'string', 'max:255'], // 255, not the panel's 2048: that is the column's width. 'website' => ['sometimes', 'nullable', 'url', 'max:255'], 'position' => ['sometimes', 'integer', 'min:0'], ]; } }