License::query()->count(), 'activeCount' => License::query()->whereNull('revoked_at')->where(function ($q): void { $q->whereNull('expires_at')->orWhere('expires_at', '>', now()); })->count(), 'productCount' => LicenseProduct::query()->count(), 'recentLicenses' => License::query()->with('product')->latest()->limit(10)->get(), ]); } public function licenses(): View { return view('licensing::admin.licenses', [ 'licenses' => License::query()->with('product')->latest()->paginate(25), ]); } public function show(License $license): View { return view('licensing::admin.show', [ 'license' => $license->load(['product', 'activations']), ]); } /** Read-only snapshot of existing licensing subscription metadata. */ public function subscriptions(): View { $subscriptions = License::query() ->whereNotNull('external_subscription_id') ->with('product') ->orderByDesc('created_at') ->paginate(25); $total = License::query()->whereNotNull('external_subscription_id')->count(); $active = License::query()->whereNotNull('external_subscription_id') ->whereIn('subscription_status', ['active', 'trialing'])->count(); $cancelScheduled = License::query()->whereNotNull('external_subscription_id') ->whereNotNull('cancel_scheduled_at')->count(); return view('licensing::admin.subscriptions', compact('subscriptions', 'total', 'active', 'cancelScheduled')); } }