Added trial and blocking to billing contract, fixed bug in running time tracker command

This commit is contained in:
Constantin Graf
2024-07-29 18:04:45 +02:00
committed by Constantin Graf
parent 7c593f8f87
commit 5b7df869ad
33 changed files with 629 additions and 187 deletions

View File

@@ -40,18 +40,18 @@ class HandleInertiaRequests extends Middleware
public function share(Request $request): array
{
$hasBilling = Module::has('Billing') && Module::isEnabled('Billing');
$billing = null;
if ($hasBilling) {
/** @var BillingContract $billing */
$billing = app(BillingContract::class);
}
/** @var BillingContract $billing */
$billing = app(BillingContract::class);
$currentOrganization = $request->user()?->currentTeam;
return array_merge(parent::share($request), [
'has_billing_extension' => $hasBilling,
'billing' => $billing !== null ? [
'has_subscription' => $currentOrganization !== null ? $billing->hasSubscription($currentOrganization) : null,
'billing' => $billing !== null && $currentOrganization !== null ? [
'has_subscription' => $billing->hasSubscription($currentOrganization),
'has_trial' => $billing->hasTrial($currentOrganization),
'is_blocked' => $billing->isBlocked($currentOrganization),
] : null,
'flash' => [
'message' => fn () => $request->session()->get('message'),