merge([ 'slug' => Str::slug((string) ($this->filled('slug') ? $this->input('slug') : $this->input('name'))), ]); } /** * Get the validation rules that apply to the request. * * @return array|string> */ public function rules(): array { return [ 'name' => ['required', 'string', 'max:255', 'unique:categories,name'], 'slug' => ['required', 'string', 'max:255', 'alpha_dash:ascii', 'unique:categories,slug'], 'description' => ['nullable', 'string', 'max:1000'], 'color' => ['required', 'string', 'regex:/^#[0-9A-Fa-f]{6}$/'], ]; } }