move into sonardesk
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Licensing\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\Licensing\Models\License;
|
||||
use Modules\Licensing\Models\LicenseProduct;
|
||||
|
||||
final class LicensingDashboardController extends Controller
|
||||
{
|
||||
public function index(): View
|
||||
{
|
||||
return view('licensing::admin.index', [
|
||||
'licenseCount' => 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'));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user