Skip to content

How can I access Parent Record for Unique validation on Relation Manager #1322

Closed Answered by ManojKiranA
ManojKiranA asked this question in Help
Discussion options

You must be logged in to vote

After searching in the docs. Found this

TextInput::make('name')
                            ->label('Region Name')
                            ->required()
                            ->reactive()
                            ->unique(static::getResource()::getModel(), 'name', function ($record) {
                                return $record;
                            }, function (Unique $rule, $record = null,$livewire) {
                                
                                return $rule
                                    ->when($record, function ($query, $record) {
                                        return $query->where('data_center_id', $record->data_center_id);
    …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ManojKiranA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant