From 18ed19c9d9c23825c196efb3d1e879d8daed9941 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 20 Dec 2019 11:57:57 +0100 Subject: [PATCH] Fix #2907 --- app/Http/Controllers/Recurring/IndexController.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Recurring/IndexController.php b/app/Http/Controllers/Recurring/IndexController.php index a6fb67f286..dd3a6bcfc9 100644 --- a/app/Http/Controllers/Recurring/IndexController.php +++ b/app/Http/Controllers/Recurring/IndexController.php @@ -82,9 +82,6 @@ class IndexController extends Controller $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page'); $pageSize = (int)app('preferences')->get('listPageSize', 50)->data; $collection = $this->recurring->get(); - $today = new Carbon; - $year = new Carbon; - $year->addYear(); // split collection $total = $collection->count(); @@ -98,6 +95,14 @@ class IndexController extends Controller $recurring = []; /** @var Recurrence $recurrence */ foreach ($recurrences as $recurrence) { + $today = new Carbon; + $year = new Carbon; + $year->addYear(); + if($recurrence->first_date > $today) { + $today =clone $recurrence->first_date; + $year = clone $today; + $year->addYear(); + } $array = $transformer->transform($recurrence); $array['first_date'] = new Carbon($array['first_date']); $array['repeat_until'] = null === $array['repeat_until'] ? null : new Carbon($array['repeat_until']);