*/ public function rules(): array { $categoryId = $this->route('category')?->id; $nameRule = $this->isMethod('post') ? 'required' : 'sometimes'; return [ 'name' => [$nameRule, 'string', 'max:255'], 'slug' => [ 'nullable', 'string', 'max:255', 'alpha_dash:ascii', Rule::unique('categories', 'slug')->ignore($categoryId), ], 'description' => ['nullable', 'string'], ]; } /** * Get custom attributes for validator errors. * * @return array */ public function attributes(): array { return [ 'name' => 'nome', 'slug' => 'slug', 'description' => 'descrição', ]; } }