in app/Http/Controllers/Settings/SubscriptionsController.php [29:65]
public function index()
{
$account = auth()->user()->account;
if (! config('monica.requires_subscription')) {
return redirect()->route('settings.index');
}
$subscription = $account->getSubscribedPlan();
if (! $account->isSubscribed() && (! $subscription || $subscription->ended())) {
return view('settings.subscriptions.blank', [
'numberOfCustomers' => InstanceHelper::getNumberOfPaidSubscribers(),
]);
}
$planId = $account->getSubscribedPlanId();
try {
$nextBillingDate = $account->getNextBillingDate();
} catch (StripeException $e) {
$nextBillingDate = trans('app.unknown');
}
$hasInvoices = $account->hasStripeId() && $account->hasInvoices();
$invoices = null;
if ($hasInvoices) {
$invoices = $account->invoices();
}
return view('settings.subscriptions.account', [
'planInformation' => InstanceHelper::getPlanInformationFromConfig($planId),
'nextBillingDate' => $nextBillingDate,
'subscription' => $subscription,
'hasInvoices' => $hasInvoices,
'invoices' => $invoices,
'accountHasLimitations' => AccountHelper::hasLimitations($account),
]);
}