mrleblanc101
`->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
3 replies