58 lines
1.7 KiB
PHP
58 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\Resources\VisitResource\Pages;
|
|
|
|
use App\Filament\Resources\VisitResource;
|
|
use Filament\Actions\CreateAction;
|
|
use Filament\Resources\Pages\ListRecords;
|
|
|
|
class ListVisits extends ListRecords
|
|
{
|
|
protected static string $resource = VisitResource::class;
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
CreateAction::make()
|
|
->icon('heroicon-o-plus'),
|
|
];
|
|
}
|
|
|
|
protected function getHeaderWidgets(): array
|
|
{
|
|
return VisitResource::getWidgets();
|
|
}
|
|
|
|
public function applyTableFilters(): void
|
|
{
|
|
parent::applyTableFilters();
|
|
$this->dispatchStatsUpdate();
|
|
}
|
|
|
|
public function updatedTableFilters(): void
|
|
{
|
|
parent::updatedTableFilters();
|
|
$this->dispatchStatsUpdate();
|
|
}
|
|
|
|
public function resetTableFiltersForm(): void
|
|
{
|
|
parent::resetTableFiltersForm();
|
|
$this->dispatchStatsUpdate();
|
|
}
|
|
|
|
protected function dispatchStatsUpdate(): void
|
|
{
|
|
$filters = $this->tableFilters ?? [];
|
|
|
|
$this->dispatch('visit-stats-updated',
|
|
fromDate: ($filters['visit_date_range']['from_date'] ?? null) ?: null,
|
|
toDate: ($filters['visit_date_range']['to_date'] ?? null) ?: null,
|
|
doctor: isset($filters['doctor']['value']) && $filters['doctor']['value'] !== '' ? (int) $filters['doctor']['value'] : null,
|
|
treatment: isset($filters['treatment']['value']) && $filters['treatment']['value'] !== '' ? (int) $filters['treatment']['value'] : null,
|
|
paymentType: isset($filters['payment_type']['value']) && $filters['payment_type']['value'] !== '' ? (int) $filters['payment_type']['value'] : null,
|
|
);
|
|
}
|
|
} |