To create and register a custom report you need to use the Aero\Admin\AdminReport facade inside of your app service providers boot method or module service providers setup method.
The facade requires a class that extends Aero\Admin\Reports\Report. Additionally, you can provide a title and summary (shown in the reports list in the admin) and any permissions required to use the report.
<?php
namespace Acme\MyModule;
use Acme\MyModule\Reports\OrdersReport;
use Aero\Admin\AdminReport;
use Aero\Common\Providers\ModuleServiceProvider;
class ServiceProvider extends ModuleServiceProvider
{
public function setup()
{
AdminReport::create(OrdersReport::class)
->title('Simple Orders Report')
->summary('View a simple report for your orders')
->permissions('orders.view');
}
}
Your report class must implement a newQuery method that must return a Illuminate\Database\Eloquent\Builder. This method provides the query your report will run from.
<?php
namespace Acme\MyModule\Reports;
use Aero\Admin\Reports\Report;
use Aero\Cart\Models\Order;
use Illuminate\Database\Eloquent\Builder;
class OrdersReport extends Report
{
protected function newQuery(): Builder
{
return Order::with([
'status', 'items', 'currency', 'discounts', 'payments.method',
]);
}
}