How do I add admin filters to my custom report?

You need to create an Admin Filter class as shown in the article "How do I create a custom report?".

To register your newly created admin filter with your report you need to ensure the report uses the Aero\Admin\Reports\Traits\HasFilters trait and that your admin filter class is in the reports protected static $filters array.

<?php

namespace Acme\MyModule\Reports;

use Aero\Admin\Filters\Order\OrderOrderedAtDateAdminFilter;
use Aero\Admin\Reports\Report;
use Aero\Admin\Reports\Traits\HasFilters;
use Aero\Cart\Models\Order;
use Illuminate\Database\Eloquent\Builder;

class OrdersReport extends Report
{
   use HasFilters;

   protected function newQuery(): Builder
   {
       return Order::with([
           'status', 'items', 'currency', 'discounts', 'payments.method',
       ]);
   }

   protected static $filters = [
       OrderOrderedAtDateAdminFilter::class,
   ];
}

Articles in this section

Was this article helpful?
0 out of 0 found this helpful