name = $data->name; } public function rules(): array { return [ 'name' => [ 'required', 'string', 'min:3', 'max:255', // Custom Closure to check the generated slug function (string $attribute, mixed $value, Closure $fail): void { $slug = Str::slug($value); // Check if the slug already exists in your database table $exists = ConnectionProvider::query() ->where('slug', $slug) ->exists(); if ($exists) { $fail("The name '{$value}' is already taken. Please choose a different name."); } }, ], ]; } }