How to add custom column?
Umar-Farooq-Shafi opened this issue · 6 comments
Umar-Farooq-Shafi commented
I want to add some custom columns in the export. e.g
public function setUp(): void
{
$types = Option::query()
->where('type', OPTION_TYPE::EMT_PROCEDURE())
->get();
foreach ($types as $type) {
$columns[] = Column::make($type->name)
->heading($type->name)
->formatStateUsing(function (Model $record) use ($type) {
if (str_contains($record->procedure, $type->name)) {
return '1';
}
return '0';
});
}
$this->withColumns($columns);
}
pxlrbt commented
And what's the issue? Maybe you need ->getStateUsing()
instead of ->formatStateUsing()
talhachughtai123 commented
@Umar-Farooq-Shafi Did you find solution?
pxlrbt commented
@talhachughtai123 Did you try the proposed solution?!
Umar-Farooq-Shafi commented
yes, thanks for the help. @pxlrbt
talhachughtai123 commented
Please tell me the solution
Umar-Farooq-Shafi commented
And what's the issue? Maybe you need ->getStateUsing() instead of ->formatStateUsing()
as @pxlrbt suggested.