Table ExportAction failing on relationship
Whenever I try to export a table and add a relationship column with the dot notation the job fails, however no error is displayed
Here is my code, the relationship is BelongsTo Funcionario, if I use funcionario_id it works but with funcionario.nome the job fails.
class EntradaExporter extends Exporter
{
protected static ?string $model = Entrada::class;
public static function getColumns(): array
{
return [
ExportColumn::make('id')
->label('ID'),
ExportColumn::make('funcionario.nome'),
ExportColumn::make('obra_id'),
ExportColumn::make('dt_entrada'),
ExportColumn::make('created_at'),
ExportColumn::make('updated_at'),
ExportColumn::make('deleted_at'),
ExportColumn::make('dt_saida'),
ExportColumn::make('created_by'),
ExportColumn::make('updated_by'),
ExportColumn::make('deleted_by'),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your entrada export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
if ($failedRowsCount = $export->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
}
return $body;
}
}
0 Replies