store/app/Http/Controllers/Admin/AnalysisController.php
Yoga Pangestu 4027363729
Some checks are pending
linter / quality (push) Waiting to run
tests / ci (8.3) (push) Waiting to run
tests / ci (8.4) (push) Waiting to run
tests / ci (8.5) (push) Waiting to run
feat: enhance analysis functionality with new revenue metrics
- Added methods to AnalysisService for retrieving monthly revenue by channel and revenue by payment type.
- Updated AnalysisController to include new metrics in the index response.
- Enhanced Analysis.vue to visualize revenue data by channel and payment type with appropriate charts and tooltips.
2026-07-29 09:36:22 +07:00

50 lines
2.6 KiB
PHP

<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Services\System\AnalysisService;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
class AnalysisController extends Controller
{
public function __construct(
private readonly AnalysisService $analysisService,
) {}
public function index(Request $request): Response
{
$startDate = $request->query('start_date') ? Carbon::parse($request->query('start_date'))->startOfDay() : null;
$endDate = $request->query('end_date') ? Carbon::parse($request->query('end_date'))->endOfDay() : null;
$user = $request->user();
return Inertia::render('admin/Analysis', [
'filters' => [
'start_date' => $request->query('start_date', ''),
'end_date' => $request->query('end_date', ''),
],
'attendance' => $this->analysisService->getAttendance($startDate, $endDate),
'myAttendance' => $user ? $this->analysisService->getMyAttendance($user, $startDate, $endDate) : null,
'isManager' => $this->analysisService->isManager($user),
'cashOverview' => $this->analysisService->getCashOverview($startDate, $endDate),
'rawMaterialStock' => $this->analysisService->getRawMaterialStock(),
'productStock' => $this->analysisService->getProductStock(),
'revenueSummary' => $this->analysisService->getRevenueSummary($startDate, $endDate),
'monthlyRevenue' => $this->analysisService->getMonthlyRevenue($startDate, $endDate),
'monthlyRevenueByChannel' => $this->analysisService->getMonthlyRevenueByChannel($startDate, $endDate),
'revenueByPaymentType' => $this->analysisService->getRevenueByPaymentType($startDate, $endDate),
'expenseSummary' => $this->analysisService->getExpenseSummary($startDate, $endDate),
'monthlyExpense' => $this->analysisService->getMonthlyExpense($startDate, $endDate),
'busyHours' => $this->analysisService->getBusyHours($startDate, $endDate),
'profitMetrics' => $this->analysisService->getProfitMetrics($startDate, $endDate),
'topSuppliers' => $this->analysisService->getTopSuppliers($startDate, $endDate),
'topCustomers' => $this->analysisService->getTopCustomers($startDate, $endDate),
'topProducts' => $this->analysisService->getTopProducts($startDate, $endDate),
'marketingSales' => $this->analysisService->getMarketingSales($startDate, $endDate),
]);
}
}