How do I add a column to an existing report?
You can use the addColumn() method(s) to add a column to an existing report:
\Aero\Admin\Reports\Implementations\SalesReport::extend(function (\Aero\Admin\Reports\Implementations\SalesReport $report, \Closure $next) {
// Add it as the first column
$report->table()->addColumn('Header', function ($row) {
return 'Content';
});
// Add it after a specific column
$report->table()->addColumnAfter('Header', function ($row) {
return 'Content';
}, 'name');
// Add it before a specific column
$report->table()->addColumnBefore('Header', function ($row) {
return 'Content';
}, 'name');
return $next($report);
});
If you need to see the keys of the existing columns in order to position your new column appropriately, you can dump them out:
\Aero\Admin\Reports\Implementations\SalesReport::extend(function (\Aero\Admin\Reports\Implementations\SalesReport $report, \Closure $next) {
dd($report->table()->getColumns()->map->key());
return $next($report);
});