Link tenant packages to events and show usage in billing
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled

This commit is contained in:
Codex Agent
2026-02-06 12:54:33 +01:00
parent fa114ac0dc
commit 0291d537fb
11 changed files with 572 additions and 51 deletions

View File

@@ -149,6 +149,7 @@ class EventController extends Controller
$eventServicePackage = $billingIsReseller
? $this->resolveResellerEventPackageForSlug($requestedServiceSlug ?: $package->included_package_slug)
: $package;
$sourceTenantPackage = $billingIsReseller ? $billingTenantPackage : $tenantPackage;
$requiresWaiver = $package->isEndcustomer();
$latestPurchase = $requiresWaiver ? $this->resolveLatestPackagePurchase($tenant, $package) : null;
@@ -216,12 +217,13 @@ class EventController extends Controller
$eventData = Arr::only($eventData, $allowed);
$event = DB::transaction(function () use ($tenant, $eventData, $eventServicePackage, $billingIsReseller, $isSuperAdmin) {
$event = DB::transaction(function () use ($tenant, $eventData, $eventServicePackage, $billingIsReseller, $isSuperAdmin, $sourceTenantPackage) {
$event = Event::create($eventData);
EventPackage::create([
'event_id' => $event->id,
'package_id' => $eventServicePackage->id,
'tenant_package_id' => $sourceTenantPackage?->id,
'purchased_price' => $billingIsReseller ? 0 : $eventServicePackage->price,
'purchased_at' => now(),
'gallery_expires_at' => $eventServicePackage->gallery_days