49 lines
1.4 KiB
PHP
49 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\BackupScheduleResource\Pages;
|
|
|
|
use App\Filament\Resources\BackupScheduleResource;
|
|
use Filament\Actions;
|
|
use Filament\Resources\Pages\ListRecords;
|
|
|
|
class ListBackupSchedules extends ListRecords
|
|
{
|
|
protected static string $resource = BackupScheduleResource::class;
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [$this->makeHeaderCreateAction()];
|
|
}
|
|
|
|
protected function getTableEmptyStateActions(): array
|
|
{
|
|
return [$this->makeEmptyStateCreateAction()];
|
|
}
|
|
|
|
private function tableHasRecords(): bool
|
|
{
|
|
return $this->getTableRecords()->count() > 0;
|
|
}
|
|
|
|
private function makeHeaderCreateAction(): Actions\CreateAction
|
|
{
|
|
return $this->makeCreateAction()
|
|
->visible(fn (): bool => $this->tableHasRecords());
|
|
}
|
|
|
|
private function makeEmptyStateCreateAction(): Actions\CreateAction
|
|
{
|
|
return $this->makeCreateAction();
|
|
}
|
|
|
|
private function makeCreateAction(): Actions\CreateAction
|
|
{
|
|
return Actions\CreateAction::make()
|
|
->label('New backup schedule')
|
|
->disabled(fn (): bool => ! BackupScheduleResource::canCreate())
|
|
->tooltip(fn (): ?string => BackupScheduleResource::canCreate()
|
|
? null
|
|
: 'You do not have permission to create backup schedules.');
|
|
}
|
|
}
|