F
Filamentβ€’15mo ago
Jaw

How can i get a value from previous column?

TextColumn::make('fileable_type')
->sortable()
->searchable()
->label('Resource')
->formatStateUsing(function ($state) {
$modelName = explode('\\', $state);
return $modelName[count($modelName) - 1];
}),
TextColumn::make('fileable_id')
->sortable()
->searchable()
->formatStateUsing(function ($state) {
// how can i get `fileable_type` here
})
TextColumn::make('fileable_type')
->sortable()
->searchable()
->label('Resource')
->formatStateUsing(function ($state) {
$modelName = explode('\\', $state);
return $modelName[count($modelName) - 1];
}),
TextColumn::make('fileable_id')
->sortable()
->searchable()
->formatStateUsing(function ($state) {
// how can i get `fileable_type` here
})
i want to retrive fileable_type in second column.
2 Replies
jouni.i
jouni.iβ€’15mo ago
>formatStateUsing(static function (Get $get) { $column = $get('collum name'); i think so πŸ™‚
Jaw
JawOPβ€’15mo ago
thanks. we can also do it this way:
->formatStateUsing(function ($state, $record) {
$modelClass = $record->fileable_type;
if (class_exists($modelClass)) {
return $modelClass::find($state)->name;
}
})
->formatStateUsing(function ($state, $record) {
$modelClass = $record->fileable_type;
if (class_exists($modelClass)) {
return $modelClass::find($state)->name;
}
})
Want results from more Discord servers?
Add your server