Добавлена страница штаба
Добавлены графики Добавлены события отчетов
This commit is contained in:
36
app/Http/Controllers/Api/HeadquartersController.php
Normal file
36
app/Http/Controllers/Api/HeadquartersController.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\DateRangeService;
|
||||
use App\Services\StatisticsService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class HeadquartersController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
protected DateRangeService $dateService,
|
||||
protected StatisticsService $statisticsService
|
||||
) {}
|
||||
|
||||
public function stats(Request $request): JsonResponse
|
||||
{
|
||||
$user = $request->user();
|
||||
$dateRange = $this->dateService->getDateRangeFromRequest($request, $user);
|
||||
$isRangeOneDay = $this->dateService->isRangeOneDay($dateRange->startDate, $dateRange->endDate);
|
||||
|
||||
$finalData = $this->statisticsService->getStatisticsData(
|
||||
$user,
|
||||
$dateRange->startDate,
|
||||
$dateRange->endDate,
|
||||
$isRangeOneDay
|
||||
);
|
||||
|
||||
return response()->json([
|
||||
'data' => $finalData['data'],
|
||||
'grandTotals' => $finalData['grandTotals'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user