Access parent $record in relation manager

Hi all Does anyone know how to access the parent $record in a relation manager? I have an attach action that I need to scope using a parent attribute. Have tried this but $record is null:
Tables\Actions\AttachAction::make()
->recordSelectOptionsQuery(function (Builder $query, Model $record) {
}
Tables\Actions\AttachAction::make()
->recordSelectOptionsQuery(function (Builder $query, Model $record) {
}
Solution:
Or $livewire->ownerRecord
Jump to solution
5 Replies
Dennis Koch
Dennis Koch4mo ago
$ownerRecord
Solution
Dennis Koch
Dennis Koch4mo ago
Or $livewire->ownerRecord
Raziul Islam
Raziul Islam4mo ago
Filament docs has this mentioned.
$this->getOwnerRecord()
$this->getOwnerRecord()
I am using this in a project like this:
Tables\Actions\CreateAction::make()
->label('Add Product')
->visible($this->getOwnerRecord()->status->isPending()),
Tables\Actions\CreateAction::make()
->label('Add Product')
->visible($this->getOwnerRecord()->status->isPending()),
binaryfire
binaryfire4mo ago
@Dennis Koch Thanks, that did the trick! @Raziul Islam Tried that but it wasn't working for me. $livewire->ownerRecord worked though.
Raziul Islam
Raziul Islam4mo ago
okay, great