Merge pull request #3011 from AreYouRlyScared/addcronmonth
Adds months for schedules
This commit is contained in:
commit
aab353d91e
12 changed files with 72 additions and 18 deletions
|
@ -42,13 +42,14 @@ class Utilities
|
|||
* @param string $minute
|
||||
* @param string $hour
|
||||
* @param string $dayOfMonth
|
||||
* @param string $month
|
||||
* @param string $dayOfWeek
|
||||
* @return \Carbon\Carbon
|
||||
*/
|
||||
public static function getScheduleNextRunDate(string $minute, string $hour, string $dayOfMonth, string $dayOfWeek)
|
||||
public static function getScheduleNextRunDate(string $minute, string $hour, string $dayOfMonth, string $month, string $dayOfWeek)
|
||||
{
|
||||
return Carbon::instance(CronExpression::factory(
|
||||
sprintf('%s %s %s * %s', $minute, $hour, $dayOfMonth, $dayOfWeek)
|
||||
sprintf('%s %s %s %s %s', $minute, $hour, $dayOfMonth, $month, $dayOfWeek)
|
||||
)->getNextRunDate());
|
||||
}
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@ class ScheduleController extends ClientApiController
|
|||
'server_id' => $server->id,
|
||||
'name' => $request->input('name'),
|
||||
'cron_day_of_week' => $request->input('day_of_week'),
|
||||
'cron_month' => $request->input('month'),
|
||||
'cron_day_of_month' => $request->input('day_of_month'),
|
||||
'cron_hour' => $request->input('hour'),
|
||||
'cron_minute' => $request->input('minute'),
|
||||
|
@ -136,6 +137,7 @@ class ScheduleController extends ClientApiController
|
|||
$data = [
|
||||
'name' => $request->input('name'),
|
||||
'cron_day_of_week' => $request->input('day_of_week'),
|
||||
'cron_month' => $request->input('month'),
|
||||
'cron_day_of_month' => $request->input('day_of_month'),
|
||||
'cron_hour' => $request->input('hour'),
|
||||
'cron_minute' => $request->input('minute'),
|
||||
|
@ -211,6 +213,7 @@ class ScheduleController extends ClientApiController
|
|||
$request->input('minute'),
|
||||
$request->input('hour'),
|
||||
$request->input('day_of_month'),
|
||||
$request->input('month'),
|
||||
$request->input('day_of_week')
|
||||
);
|
||||
} catch (Exception $exception) {
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -40,6 +40,7 @@ class ScheduleTransformer extends BaseClientTransformer
|
|||
'cron' => [
|
||||
'day_of_week' => $model->cron_day_of_week,
|
||||
'day_of_month' => $model->cron_day_of_month,
|
||||
'month' => $model->cron_month,
|
||||
'hour' => $model->cron_hour,
|
||||
'minute' => $model->cron_minute,
|
||||
],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue