Unify SSO and surface legacy ResellerClub hosting orders on the dashboard.
Deploy Ladill Hosting / deploy (push) Successful in 26s
Deploy Ladill Hosting / deploy (push) Successful in 26s
Add silent OAuth and session keepalive, and show imported RC orders alongside native hosting accounts. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -7,9 +7,11 @@ use App\Models\CustomerHostingOrder;
|
||||
use App\Models\HostedSite;
|
||||
use App\Models\HostingAccount;
|
||||
use App\Models\HostingAccountMember;
|
||||
use App\Models\HostingOrder;
|
||||
use App\Models\HostingProduct;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Collection as SupportCollection;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
@@ -20,6 +22,7 @@ class OverviewController extends Controller
|
||||
{
|
||||
$user = $request->user();
|
||||
$accounts = $this->sharedHostingAccounts($user);
|
||||
$legacyOrders = $this->legacySharedHostingOrders($user);
|
||||
$accountIds = $accounts->pluck('id');
|
||||
|
||||
$pendingOrders = CustomerHostingOrder::query()
|
||||
@@ -36,17 +39,24 @@ class OverviewController extends Controller
|
||||
->take(5)
|
||||
->get();
|
||||
|
||||
$linkedDomains = $accountIds->isEmpty()
|
||||
$linkedDomains = ($accountIds->isEmpty()
|
||||
? 0
|
||||
: HostedSite::query()->whereIn('hosting_account_id', $accountIds)->count();
|
||||
: HostedSite::query()->whereIn('hosting_account_id', $accountIds)->count())
|
||||
+ $legacyOrders->filter(fn (HostingOrder $order) => filled($order->domain_name))->count();
|
||||
|
||||
return view('hosting.dashboard', [
|
||||
'accounts' => $accounts,
|
||||
'activeCount' => $accounts->where('status', HostingAccount::STATUS_ACTIVE)->count(),
|
||||
'legacyOrders' => $legacyOrders,
|
||||
'activeCount' => $accounts->where('status', HostingAccount::STATUS_ACTIVE)->count()
|
||||
+ $legacyOrders->where('status', HostingOrder::STATUS_ACTIVE)->count(),
|
||||
'expiringCount' => $accounts
|
||||
->where('status', HostingAccount::STATUS_ACTIVE)
|
||||
->filter(fn (HostingAccount $account) => $account->expires_at !== null && $account->expires_at->between(now(), now()->addDays(30)))
|
||||
->count(),
|
||||
->count()
|
||||
+ $legacyOrders
|
||||
->where('status', HostingOrder::STATUS_ACTIVE)
|
||||
->filter(fn (HostingOrder $order) => $order->expires_at !== null && $order->expires_at->between(now(), now()->addDays(30)))
|
||||
->count(),
|
||||
'pendingOrderCount' => CustomerHostingOrder::query()
|
||||
->forUser($user->id)
|
||||
->whereHas('product', fn ($q) => $q->whereIn('type', $this->sharedTypes()))
|
||||
@@ -59,15 +69,19 @@ class OverviewController extends Controller
|
||||
->count(),
|
||||
'linkedDomains' => $linkedDomains,
|
||||
'recent' => $accounts->take(5),
|
||||
'recentLegacyOrders' => $legacyOrders->take(5),
|
||||
'pendingOrders' => $pendingOrders,
|
||||
]);
|
||||
}
|
||||
|
||||
public function accounts(Request $request): View
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
return view('hosting.accounts-list', [
|
||||
'title' => 'Your Hosting Accounts',
|
||||
'accounts' => $this->sharedHostingAccounts($request->user()),
|
||||
'accounts' => $this->sharedHostingAccounts($user),
|
||||
'legacyOrders' => $this->legacySharedHostingOrders($user),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -113,4 +127,19 @@ class OverviewController extends Controller
|
||||
|
||||
return $hostingAccounts->merge($orderAccounts)->unique('id')->values();
|
||||
}
|
||||
|
||||
/** @return SupportCollection<int, HostingOrder> */
|
||||
private function legacySharedHostingOrders(User $user): SupportCollection
|
||||
{
|
||||
return HostingOrder::query()
|
||||
->where('user_id', $user->id)
|
||||
->whereIn('hosting_type', [
|
||||
HostingOrder::TYPE_SINGLE_DOMAIN,
|
||||
HostingOrder::TYPE_MULTI_DOMAIN,
|
||||
HostingOrder::TYPE_RESELLER,
|
||||
])
|
||||
->whereNotIn('status', [HostingOrder::STATUS_CANCELLED])
|
||||
->latest()
|
||||
->get();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user