From 16a511cf79920dcf5a6680d5cf9342a9c980285d Mon Sep 17 00:00:00 2001 From: Florian Dupret Date: Tue, 16 Jun 2020 18:02:48 +0200 Subject: [PATCH] move 7c78708 logic from transformer to controller --- app/Http/Controllers/BillController.php | 2 ++ app/Transformers/BillTransformer.php | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/BillController.php b/app/Http/Controllers/BillController.php index 2c12d48479..a11e77bfae 100644 --- a/app/Http/Controllers/BillController.php +++ b/app/Http/Controllers/BillController.php @@ -212,6 +212,8 @@ class BillController extends Controller $bills = $unfiltered->map( function (Bill $bill) use ($transformer, $defaultCurrency) { $return = $transformer->transform($bill); + $nextExpectedMatch = new Carbon($return['next_expected_match']); + $return['next_expected_match_diff'] = $nextExpectedMatch->isToday() ? trans('firefly.today') : $nextExpectedMatch->diffForHumans(today(), Carbon::DIFF_RELATIVE_TO_NOW); $currency = $bill->transactionCurrency ?? $defaultCurrency; $return['currency_id'] = $currency->id; $return['currency_name'] = $currency->name; diff --git a/app/Transformers/BillTransformer.php b/app/Transformers/BillTransformer.php index e8210311ae..48503732fd 100644 --- a/app/Transformers/BillTransformer.php +++ b/app/Transformers/BillTransformer.php @@ -83,8 +83,7 @@ class BillTransformer extends AbstractTransformer 'skip' => (int)$bill->skip, 'active' => $bill->active, 'notes' => $notes, - 'next_expected_match' => $paidData['next_expected_match']->format('Y-m-d'), - 'next_expected_match_diff'=> $paidData['next_expected_match']->isToday() ? trans('firefly.today') : $paidData['next_expected_match']->diffForHumans(Carbon::today(), Carbon::DIFF_RELATIVE_TO_NOW), + 'next_expected_match' => $paidData['next_expected_match'], 'pay_dates' => $payDates, 'paid_dates' => $paidData['paid_dates'], 'links' => [ @@ -217,7 +216,7 @@ class BillTransformer extends AbstractTransformer } $result = [ 'paid_dates' => $result, - 'next_expected_match' => $nextMatch, + 'next_expected_match' => $nextMatch->format('Y-m-d'), ]; Log::debug('Result', $result);