Best practice to know if I'm in the resource or in the relationI have a form inside a resour manager

I have a form inside a resource that I use inside a relationship manager. I need to modify unique rule with modifyRuleUsing and for that I need to use the livewire component in the relation manager to get the resource ID and a select value in the resource. How do you know if I'm inside the resource or inside the relationship manager? Now I'm doing like this:
Forms\Components\TextInput::make('name')
->unique(ignoreRecord: true, modifyRuleUsing: function (Unique $rule, Get $get, Edition $edition, $livewire) {
$editionId = $livewire?->ownerRecord?->id ?? $get('edition_id');
return $rule->where('edition_id', $editionId);
})
->required(),
Forms\Components\TextInput::make('name')
->unique(ignoreRecord: true, modifyRuleUsing: function (Unique $rule, Get $get, Edition $edition, $livewire) {
$editionId = $livewire?->ownerRecord?->id ?? $get('edition_id');
return $rule->where('edition_id', $editionId);
})
->required(),
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server