mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-10-31 22:56:52 +01:00 
			
		
		
		
	 1900c04b71
			
		
	
	
		1900c04b71
		
			
		
	
	
	
	
		
			
			Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com> Co-authored-by: Boy132 <Boy132@users.noreply.github.com> Co-authored-by: Lance Pioch <git@lance.sh>
		
			
				
	
	
		
			60 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			60 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Filament\Server\Resources\Schedules\Pages;
 | |
| 
 | |
| use App\Facades\Activity;
 | |
| use App\Filament\Server\Resources\Schedules\ScheduleResource;
 | |
| use App\Models\Schedule;
 | |
| use App\Models\Server;
 | |
| use App\Traits\Filament\CanCustomizeHeaderActions;
 | |
| use App\Traits\Filament\CanCustomizeHeaderWidgets;
 | |
| use Filament\Facades\Filament;
 | |
| use Filament\Resources\Pages\CreateRecord;
 | |
| 
 | |
| class CreateSchedule extends CreateRecord
 | |
| {
 | |
|     use CanCustomizeHeaderActions;
 | |
|     use CanCustomizeHeaderWidgets;
 | |
| 
 | |
|     protected static string $resource = ScheduleResource::class;
 | |
| 
 | |
|     protected static bool $canCreateAnother = false;
 | |
| 
 | |
|     protected function afterCreate(): void
 | |
|     {
 | |
|         /** @var Schedule $schedule */
 | |
|         $schedule = $this->record;
 | |
| 
 | |
|         Activity::event('server:schedule.create')
 | |
|             ->property('name', $schedule->name)
 | |
|             ->log();
 | |
|     }
 | |
| 
 | |
|     protected function mutateFormDataBeforeCreate(array $data): array
 | |
|     {
 | |
|         if (!isset($data['server_id'])) {
 | |
|             /** @var Server $server */
 | |
|             $server = Filament::getTenant();
 | |
| 
 | |
|             $data['server_id'] = $server->id;
 | |
|         }
 | |
| 
 | |
|         if (!isset($data['next_run_at'])) {
 | |
|             $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;
 | |
|     }
 | |
| 
 | |
|     public function getBreadcrumbs(): array
 | |
|     {
 | |
|         return [];
 | |
|     }
 | |
| }
 |