Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/WalletsController.php
Show First 20 Lines • Show All 226 Lines • ▼ Show 20 Lines | protected function getWalletNotice(Wallet $wallet): ?string | ||||
return \trans('app.wallet-notice-nocredit'); | return \trans('app.wallet-notice-nocredit'); | ||||
} | } | ||||
// the discount is 100%, no credit is needed | // the discount is 100%, no credit is needed | ||||
if ($wallet->discount && $wallet->discount->discount == 100) { | if ($wallet->discount && $wallet->discount->discount == 100) { | ||||
return null; | return null; | ||||
} | } | ||||
// the owner was created less than a month ago | $plan = $wallet->plan(); | ||||
if ($wallet->owner->created_at > Carbon::now()->subMonthsWithoutOverflow(1)) { | $freeMonths = $plan ? $plan->free_months : 0; | ||||
// but more than two weeks ago, notice of trial ending | $trialEnd = $freeMonths ? $wallet->owner->created_at->copy()->addMonthsWithoutOverflow($freeMonths) : null; | ||||
if ($wallet->owner->created_at <= Carbon::now()->subWeeks(2)) { | |||||
// the owner is still in the trial period | |||||
if ($trialEnd && $trialEnd > Carbon::now()) { | |||||
// notice of trial ending if less than 2 weeks left | |||||
if ($trialEnd < Carbon::now()->addWeeks(2)) { | |||||
return \trans('app.wallet-notice-trial-end'); | return \trans('app.wallet-notice-trial-end'); | ||||
} | } | ||||
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()) { | ||||
Show All 28 Lines |