F
Filament16mo ago
wotroe

Hide column in relationmanager based on parent model

I've Ctrl+F'ed through the server in the hopes that I could find a solution, but unfortunately couldn't find a result that solved my issue. I'm trying to hide a column in a RelationManager if the parent record has a specific import_type, but I couldn't figure out how to pull this off since the table method is static, and the getOwnerRecord isn't. Any suggestions? Thanks in advance!
Tables\Columns\TextColumn::make('total_quantity')
->suffix(' points')
->hidden($this->getOwnerRecord()->import_type->hasCustomUnitPricing())
->formatStateUsing(fn(?string $state): string => (double) $state)
->sortable(),
Tables\Columns\TextColumn::make('total_quantity')
->suffix(' points')
->hidden($this->getOwnerRecord()->import_type->hasCustomUnitPricing())
->formatStateUsing(fn(?string $state): string => (double) $state)
->sortable(),
This was what I had in mind, but this unfortunately doesn't work since I can't use $this in a static function.
Solution:
This could work: ```php ->hidden( fn ($livewire) => $livewire->getOwnerRecord()...
Jump to solution
2 Replies
Solution
Dennis Koch
Dennis Koch16mo ago
This could work:
->hidden(
fn ($livewire) => $livewire->getOwnerRecord()
->import_type
->hasCustomUnitPricing()
)
->hidden(
fn ($livewire) => $livewire->getOwnerRecord()
->import_type
->hasCustomUnitPricing()
)
wotroe
wotroeOP16mo ago
Sweet! That works, really appreciate the good & quick reply
Want results from more Discord servers?
Add your server