Fix endcustomer package allocation and event create gating
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 13:21:11 +01:00
parent 0291d537fb
commit df00deb0df
11 changed files with 409 additions and 14 deletions

View File

@@ -110,7 +110,14 @@ class EventController extends Controller
$tenantPackage = $tenant->tenantPackages()
->with('package')
->where('active', true)
->where(function ($query) {
$query->whereNull('expires_at')->orWhere('expires_at', '>', now());
})
->whereHas('package', fn ($query) => $query->withTrashed()->where('type', 'endcustomer'))
->withCount('eventPackages')
->orderBy('event_packages_count')
->orderByDesc('purchased_at')
->orderByDesc('id')
->first();
$package = null;