Is there a way to limit the amount of relations that can be selected when using a relationship

Is there a way when clicking Add Product and they select a product , you only allow a max of 3 to be selected
No description
2 Replies
cheesegrits
cheesegrits2y ago
You could probably disable the create action once there are three records in the relationship, something like ...
CreateAction::make()
->disabled(fn (RelationManager $livewire): bool =>
$livewire->getOwnerRecord()?->products->count() >= 3;
),
CreateAction::make()
->disabled(fn (RelationManager $livewire): bool =>
$livewire->getOwnerRecord()?->products->count() >= 3;
),
Codata
CodataOP2y ago
I will take a look , thank you

Did you find this page helpful?