Files
ladill-servers/app/Http/Controllers/Hosting/OverviewController.php
T
isaaccladandCursor b6c8ac343f Extract Ladill Servers as standalone app at servers.ladill.com.
VPS and dedicated server ordering, managed panels, SSO, billing, and launcher integration — forked from hosting infrastructure with server-focused routes and dashboard.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-06 19:18:30 +00:00

54 lines
1.8 KiB
PHP

<?php
namespace App\Http\Controllers\Hosting;
use App\Http\Controllers\Controller;
use App\Models\CustomerHostingOrder;
use App\Models\HostingProduct;
use Illuminate\Http\Request;
use Illuminate\View\View;
class OverviewController extends Controller
{
/** Authenticated servers dashboard (VPS + dedicated overview). */
public function index(Request $request): View
{
$user = $request->user();
$serverTypes = $this->serverTypes();
$orders = CustomerHostingOrder::query()
->forUser($user->id)
->whereHas('product', fn ($q) => $q->whereIn('type', $serverTypes))
->with('product')
->latest()
->get();
$activeOrders = $orders->where('status', CustomerHostingOrder::STATUS_ACTIVE);
$pendingOrders = $orders->whereIn('status', [
CustomerHostingOrder::STATUS_PENDING_PAYMENT,
CustomerHostingOrder::STATUS_PENDING_APPROVAL,
CustomerHostingOrder::STATUS_APPROVED,
CustomerHostingOrder::STATUS_PROVISIONING,
]);
return view('servers.dashboard', [
'orders' => $orders,
'activeCount' => $activeOrders->count(),
'vpsCount' => $activeOrders->filter(fn (CustomerHostingOrder $order) => $order->product?->type === HostingProduct::TYPE_VPS)->count(),
'dedicatedCount' => $activeOrders->filter(fn (CustomerHostingOrder $order) => $order->product?->type === HostingProduct::TYPE_DEDICATED)->count(),
'pendingOrderCount' => $pendingOrders->count(),
'recent' => $orders->take(8),
'pendingOrders' => $pendingOrders->take(5),
]);
}
/** @return list<string> */
private function serverTypes(): array
{
return [
HostingProduct::TYPE_VPS,
HostingProduct::TYPE_DEDICATED,
];
}
}