F
Filament15mo ago
Codata

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
cheesegrits15mo 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
CodataOP15mo ago
I will take a look , thank you
Want results from more Discord servers?
Add your server