Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/WalletsController.php
Show First 20 Lines • Show All 310 Lines • ▼ Show 20 Lines | protected function getWalletNotice(Wallet $wallet): ?string | ||||
return \trans('app.wallet-notice-trial'); | return \trans('app.wallet-notice-trial'); | ||||
} | } | ||||
if ($until = $wallet->balanceLastsUntil()) { | if ($until = $wallet->balanceLastsUntil()) { | ||||
if ($until->isToday()) { | if ($until->isToday()) { | ||||
return \trans('app.wallet-notice-today'); | return \trans('app.wallet-notice-today'); | ||||
} | } | ||||
// Once in a while we got e.g. "3 weeks" instead of expected "4 weeks". | |||||
// It's because $until uses full seconds, but $now is more precise. | |||||
// We make sure both have the same time set. | |||||
$now = Carbon::now()->setTimeFrom($until); | |||||
$params = [ | $params = [ | ||||
'date' => $until->toDateString(), | 'date' => $until->toDateString(), | ||||
'days' => Carbon::now()->diffForHumans($until, Carbon::DIFF_ABSOLUTE), | 'days' => $now->diffForHumans($until, Carbon::DIFF_ABSOLUTE), | ||||
]; | ]; | ||||
return \trans('app.wallet-notice-date', $params); | return \trans('app.wallet-notice-date', $params); | ||||
} | } | ||||
return null; | return null; | ||||
} | } | ||||
} | } |