Fix settings array mapping and non-saas dashboard queries
This commit is contained in:
@@ -88,11 +88,17 @@ class DashboardController extends Controller
|
||||
// Get system-wide statistics
|
||||
$totalCompanies = User::where('type', 'company')->count();
|
||||
$totalUsers = User::where('type', '!=', 'superadmin')->where('type', '!=', 'super admin')->count();
|
||||
$totalRevenue = PlanOrder::where('status', 'approved')->sum('final_price') ?? 0;
|
||||
$activePlans = Plan::where('is_plan_enable', 'on')->count();
|
||||
$totalRevenue = 0;
|
||||
$activePlans = 0;
|
||||
$pendingRequests = 0;
|
||||
$activeCoupons = 0;
|
||||
|
||||
$pendingRequests = PlanRequest::where('status', 'pending')->count();
|
||||
$activeCoupons = Coupon::where('status', true)->count();
|
||||
if (isSaas()) {
|
||||
$totalRevenue = PlanOrder::where('status', 'approved')->sum('final_price') ?? 0;
|
||||
$activePlans = Plan::where('is_plan_enable', 'on')->count();
|
||||
$pendingRequests = PlanRequest::where('status', 'pending')->count();
|
||||
$activeCoupons = Coupon::where('status', true)->count();
|
||||
}
|
||||
|
||||
// Calculate monthly growth for companies
|
||||
$currentMonthCompanies = User::where('type', 'company')
|
||||
@@ -130,7 +136,7 @@ class DashboardController extends Controller
|
||||
'status' => 'active',
|
||||
];
|
||||
}),
|
||||
'topPlans' => Plan::withCount('users')
|
||||
'topPlans' => isSaas() ? Plan::withCount('users')
|
||||
->orderBy('users_count', 'desc')
|
||||
->take(5)
|
||||
->get()
|
||||
@@ -140,7 +146,7 @@ class DashboardController extends Controller
|
||||
'subscribers' => $plan->users_count,
|
||||
'revenue' => $plan->users_count * $plan->price,
|
||||
];
|
||||
}),
|
||||
}) : [],
|
||||
];
|
||||
|
||||
return Inertia::render('superadmin/dashboard', props: [
|
||||
|
||||
Reference in New Issue
Block a user