Adds months for schedules

Adds month variable for schedules
This commit is contained in:
Charles Morgan 2021-01-16 22:07:39 -05:00
parent 9684456480
commit ffeedf17e4
12 changed files with 65 additions and 11 deletions

View file

@ -12,6 +12,7 @@ use Pterodactyl\Contracts\Extensions\HashidsInterface;
* @property int $server_id
* @property string $name
* @property string $cron_day_of_week
* @property string $cron_month
* @property string $cron_day_of_month
* @property string $cron_hour
* @property string $cron_minute
@ -58,6 +59,7 @@ class Schedule extends Model
'server_id',
'name',
'cron_day_of_week',
'cron_month',
'cron_day_of_month',
'cron_hour',
'cron_minute',
@ -93,6 +95,7 @@ class Schedule extends Model
protected $attributes = [
'name' => null,
'cron_day_of_week' => '*',
'cron_month' => '*',
'cron_day_of_month' => '*',
'cron_hour' => '*',
'cron_minute' => '*',
@ -107,6 +110,7 @@ class Schedule extends Model
'server_id' => 'required|exists:servers,id',
'name' => 'required|string|max:191',
'cron_day_of_week' => 'required|string',
'cron_month' => 'required|string',
'cron_day_of_month' => 'required|string',
'cron_hour' => 'required|string',
'cron_minute' => 'required|string',
@ -123,7 +127,7 @@ class Schedule extends Model
*/
public function getNextRunDate()
{
$formatted = sprintf('%s %s %s * %s', $this->cron_minute, $this->cron_hour, $this->cron_day_of_month, $this->cron_day_of_week);
$formatted = sprintf('%s %s %s %s %s', $this->cron_minute, $this->cron_hour, $this->cron_day_of_month, $this->cron_month, $this->cron_day_of_week);
return CarbonImmutable::createFromTimestamp(
CronExpression::factory($formatted)->getNextRunDate()->getTimestamp()