<?php

declare(strict_types=1);

namespace App\Filament\Resources\DberpSupplierPerformances\Pages;

use App\Business\Report\PurchaseReportService;
use App\Filament\Resources\DberpSupplierPerformances\DberpSupplierPerformanceResource;
use Filament\Resources\Pages\ListRecords;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Database\Eloquent\Builder;

class ListDberpSupplierPerformances extends ListRecords
{
    protected static string $resource = DberpSupplierPerformanceResource::class;

    public function getSubheading(): string|Htmlable|null
    {
        return __('dberp.resources.supplier_performance.scope_hint');
    }

    protected function getTableQuery(): Builder
    {
        return app(PurchaseReportService::class)->supplierPerformanceQuery(
            PurchaseReportService::filtersFromTableState(
                is_array($this->tableFilters) ? $this->tableFilters : null,
            ),
        );
    }
}
