mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 01:44:45 +02:00

* update `next_run_at` when editing & show notification if cron is invalid * move getNextRun to resource
62 lines
1.5 KiB
PHP
62 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Server\Resources\ScheduleResource\Pages;
|
|
|
|
use App\Facades\Activity;
|
|
use App\Filament\Server\Resources\ScheduleResource;
|
|
use App\Models\Schedule;
|
|
use Filament\Actions;
|
|
use Filament\Resources\Pages\EditRecord;
|
|
|
|
class EditSchedule extends EditRecord
|
|
{
|
|
protected static string $resource = ScheduleResource::class;
|
|
|
|
protected function afterSave(): void
|
|
{
|
|
/** @var Schedule $schedule */
|
|
$schedule = $this->record;
|
|
|
|
Activity::event('server:schedule.update')
|
|
->property('name', $schedule->name)
|
|
->log();
|
|
}
|
|
|
|
protected function mutateFormDataBeforeSave(array $data): array
|
|
{
|
|
$data['next_run_at'] = ScheduleResource::getNextRun(
|
|
$data['cron_minute'],
|
|
$data['cron_hour'],
|
|
$data['cron_day_of_month'],
|
|
$data['cron_month'],
|
|
$data['cron_day_of_week']
|
|
);
|
|
|
|
return $data;
|
|
}
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
Actions\DeleteAction::make()
|
|
->after(function ($record) {
|
|
Activity::event('server:schedule.delete')
|
|
->property('name', $record->name)
|
|
->log();
|
|
}),
|
|
$this->getSaveFormAction()->formId('form')->label('Save'),
|
|
$this->getCancelFormAction()->formId('form'),
|
|
];
|
|
}
|
|
|
|
public function getBreadcrumbs(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
protected function getFormActions(): array
|
|
{
|
|
return [];
|
|
}
|
|
}
|