mirror of
https://github.com/pelican-dev/panel.git
synced 2025-08-03 14:12:13 +02:00
54 lines
1.6 KiB
PHP
54 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Components\Forms\Actions;
|
|
|
|
use Filament\Forms\Components\Actions\Action;
|
|
use Filament\Forms\Get;
|
|
use Filament\Forms\Set;
|
|
|
|
class CronPresetAction extends Action
|
|
{
|
|
protected string $minute = '0';
|
|
|
|
protected string $hour = '0';
|
|
|
|
protected string $dayOfMonth = '*';
|
|
|
|
protected string $month = '*';
|
|
|
|
protected string $dayOfWeek = '*';
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->disabled(fn (string $operation) => $operation === 'view');
|
|
|
|
$this->color(fn (Get $get) => $get('cron_minute') == $this->minute &&
|
|
$get('cron_hour') == $this->hour &&
|
|
$get('cron_day_of_month') == $this->dayOfMonth &&
|
|
$get('cron_month') == $this->month &&
|
|
$get('cron_day_of_week') == $this->dayOfWeek
|
|
? 'success' : 'primary');
|
|
|
|
$this->action(function (Set $set) {
|
|
$set('cron_minute', $this->minute);
|
|
$set('cron_hour', $this->hour);
|
|
$set('cron_day_of_month', $this->dayOfMonth);
|
|
$set('cron_month', $this->month);
|
|
$set('cron_day_of_week', $this->dayOfWeek);
|
|
});
|
|
}
|
|
|
|
public function cron(string $minute, string $hour, string $dayOfMonth, string $month, string $dayOfWeek): static
|
|
{
|
|
$this->minute = $minute;
|
|
$this->hour = $hour;
|
|
$this->dayOfMonth = $dayOfMonth;
|
|
$this->month = $month;
|
|
$this->dayOfWeek = $dayOfWeek;
|
|
|
|
return $this;
|
|
}
|
|
}
|