I have a Nova v4 metric that does this calculation to get related data from another table to be shown in the same resource view.
class ReportOrderSum extends Value
{
public function __construct(protected string $column, $component = null)
{
parent::__construct($component);
}
public function calculate(NovaRequest $request)
{
$query = Order::where('status', 'completed');
return $this
->sum($request, $query, $this->column)
->transform(fn($value) => $value / 100)
->format([
'thousandSeparated' => true,
'mantissa' => 2,
])
->dollars();
}
}
This is used in the Reports resource to get related data from the orders table.
It is added to the Reports resource like this:
public function cards(NovaRequest $request)
{
return [
Metrics\ReportOrderSum::make('fees')
->defaultRange('ALL')
->width('1/4')
->refreshWhenFiltersChange(),
];
}
However, the reports also have filters that use columns not on the orders table, so if I apply any filters, they are not always guaranteed to be compatible with the orders query so I get errors.
How do I remove the filter based query conditions for this metric that are incompatible?