- Fixed database relationships: LlmRequest now properly uses gateway_user_id instead of user_id - Updated Models: GatewayUser and LlmRequest relationships corrected - Removed User->llmRequests relationship (admin users don't have LLM requests) - Simplified Dashboard: Now shows Gateway User statistics instead of admin users - Removed obsolete Budgets management pages (budgets handled directly in gateway_users) - Removed User Budgets admin section (redundant with gateway_users management) - Fixed view errors: Added null-checks for user_id in keys views - Updated navigation: Removed Budget and User Budget links - Updated routes: Cleaned up unused BudgetController and UserManagementController routes - Simplified StatisticsService: Focus on gateway_users and basic metrics only
41 lines
922 B
PHP
41 lines
922 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Services\StatisticsService;
|
|
use Illuminate\Http\Request;
|
|
|
|
class DashboardController extends Controller
|
|
{
|
|
public function __construct(
|
|
private StatisticsService $statsService
|
|
) {}
|
|
|
|
/**
|
|
* Display the dashboard
|
|
*/
|
|
public function index()
|
|
{
|
|
$stats = $this->statsService->getDashboardStats();
|
|
$dailyUsage = $this->statsService->getDailyUsageChart(30);
|
|
$providerStats = $this->statsService->getUsageByProvider(30);
|
|
|
|
return view('dashboard', compact(
|
|
'stats',
|
|
'dailyUsage',
|
|
'providerStats'
|
|
));
|
|
}
|
|
|
|
/**
|
|
* Get real-time stats via AJAX
|
|
*/
|
|
public function realtimeStats()
|
|
{
|
|
return response()->json([
|
|
'stats' => $this->statsService->getDashboardStats(),
|
|
'timestamp' => now()->toIso8601String(),
|
|
]);
|
|
}
|
|
}
|