- Refactored the dashboard component to include attendance, revenue, and expense summaries. - Added donut charts for order statistics by channel, payment type, marketing, and status. - Implemented a greeting message based on the current time and user information. - Updated routing to use DashboardController for the dashboard view. - Introduced a new AnalysisController for future analysis features.
39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Services\DashboardService;
|
|
use Illuminate\Http\Request;
|
|
use Inertia\Inertia;
|
|
use Inertia\Response;
|
|
|
|
class DashboardController extends Controller
|
|
{
|
|
public function __construct(
|
|
private DashboardService $service
|
|
) {}
|
|
|
|
public function __invoke(Request $request): Response
|
|
{
|
|
$user = $request->user();
|
|
|
|
$attendance = $this->service->getAttendanceStats();
|
|
$revenueSummary = $this->service->getRevenueSummary();
|
|
$expenseSummary = $this->service->getExpenseSummary();
|
|
$orderStats = $this->service->getOrderStats();
|
|
$todayAttendance = $this->service->getTodayAttendance($user);
|
|
$isOnLeave = $this->service->isOnLeave($user);
|
|
$canCheckIn = $user->employee !== null;
|
|
|
|
return Inertia::render('dashboard', [
|
|
'attendance' => $attendance,
|
|
'revenueSummary' => $revenueSummary,
|
|
'expenseSummary' => $expenseSummary,
|
|
'orderStats' => $orderStats,
|
|
'todayAttendance' => $todayAttendance,
|
|
'isOnLeave' => $isOnLeave,
|
|
'canCheckIn' => $canCheckIn,
|
|
]);
|
|
}
|
|
}
|