Unique and RelationManagers

I have a relation manager for my RecipeResource. The Relationamanager has itself a form, with a Datepicker field:
public static function form(Form $form): Form
{
return $form
->schema([
TextInput::make("name"),
DatePicker::make("published_at")
->unique(callback: function(Unique $rule) {
return $rule
->where("recipe_id", "XXX");
})
->default(now())
->required()
]);
}
public static function form(Form $form): Form
{
return $form
->schema([
TextInput::make("name"),
DatePicker::make("published_at")
->unique(callback: function(Unique $rule) {
return $rule
->where("recipe_id", "XXX");
})
->default(now())
->required()
]);
}
The date should be unique within the Recipe. How do I get the recipe_id inside the unique callback (the XXXin the code)? As far as I understand is $rule the only param for the callback.
2 Replies
Dan Harrin
Dan Harrin2y ago
$livewire->ownerRecord->id
bernhard
bernhardOP2y ago
Thanks. That solved it!
Want results from more Discord servers?
Add your server