fedi-feed-router/app/Http/Controllers/Api/V1/DashboardController.php
myrmidex 6784af2ff6
Some checks failed
CI / ci (push) Failing after 4m31s
25 - Fix all PHPStan errors and add mockery extension
2026-03-08 14:18:28 +01:00

43 lines
1.2 KiB
PHP

<?php
namespace App\Http\Controllers\Api\V1;
use App\Models\Article;
use App\Services\DashboardStatsService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class DashboardController extends BaseController
{
public function __construct(
private DashboardStatsService $dashboardStatsService
) {}
/**
* Get dashboard statistics
*/
public function stats(Request $request): JsonResponse
{
$period = $request->get('period', 'today');
try {
// Get article stats from service
$articleStats = $this->dashboardStatsService->getStats($period);
// Get system stats
$systemStats = $this->dashboardStatsService->getSystemStats();
// Get available periods
$availablePeriods = $this->dashboardStatsService->getAvailablePeriods();
return $this->sendResponse([
'article_stats' => $articleStats,
'system_stats' => $systemStats,
'available_periods' => $availablePeriods,
'current_period' => $period,
]);
} catch (\Exception $e) {
return $this->sendError('Failed to fetch dashboard stats: '.$e->getMessage(), [], 500);
}
}
}