Extra content to fix recurrences.

This commit is contained in:
James Cole
2021-03-15 08:51:21 +01:00
parent 8d84dfb3aa
commit 1783f0beb1
5 changed files with 137 additions and 29 deletions

View File

@@ -80,6 +80,7 @@ class RecurrenceFactory
$description = '';
$applyRules = true;
$active = true;
$repeatUntilString = null;
if (array_key_exists('first_date', $data['recurrence'])) {
/** @var Carbon $firstDate */
$firstDate = $data['recurrence']['first_date'];
@@ -102,8 +103,8 @@ class RecurrenceFactory
if (array_key_exists('active', $data['recurrence'])) {
$active = $data['recurrence']['active'];
}
if ($repetitions > 0 && null === $repeatUntil) {
$repeatUntil = Carbon::create()->addyear();
if (null !== $repeatUntil) {
$repeatUntilString = $repeatUntil->format('Y-m-d');
}
$recurrence = new Recurrence(
@@ -113,7 +114,7 @@ class RecurrenceFactory
'title' => $title,
'description' => $description,
'first_date' => $firstDate ? $firstDate->format('Y-m-d') : null,
'repeat_until' => $repetitions > 0 ? null : $repeatUntil->format('Y-m-d'),
'repeat_until' => $repetitions > 0 ? null : $repeatUntilString,
'latest_date' => null,
'repetitions' => $repetitions,
'apply_rules' => $applyRules,