`->unique()` rule inside relationship instead of whole table
Hey guys,
I have this url
/{clientSlug}/{productSlug}
On ClientResource
, I have a ->unique(ignoreRecord: true)
on the slug field and this works fine.
Now I want to be able to create multiple product with the same productSlug unless they have the same parent (client).
I found ->unique(modifyRuleUsing: function (Unique $rule, $record)
but I'm not sure how to implement this.
Basically, I want to be able to do /client-1/product-1
and /client-2/product-1
.
But I don't want to be able to create multiple product-1
on client-1
Solution:Jump to solution
I think I got it:
```php
Forms\Components\Select::make('client_id')
->relationship('client', 'name')
->required()...
1 Reply
Solution
I think I got it: