2025-12-01 06:41:22 +07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
2025-12-19 00:21:25 +07:00
|
|
|
use App\Services\Dashboard\DashboardService;
|
|
|
|
|
use Illuminate\View\View;
|
2025-12-01 06:41:22 +07:00
|
|
|
|
|
|
|
|
class DashboardsController extends Controller
|
|
|
|
|
{
|
2025-12-19 00:21:25 +07:00
|
|
|
public function __construct(private readonly DashboardService $dashboard)
|
2025-12-01 06:41:22 +07:00
|
|
|
{
|
2025-12-19 00:21:25 +07:00
|
|
|
}
|
2025-12-01 09:40:12 +07:00
|
|
|
|
2025-12-19 00:21:25 +07:00
|
|
|
public function index(): View
|
|
|
|
|
{
|
|
|
|
|
$user = auth()->user();
|
|
|
|
|
$data = $this->dashboard->build($user);
|
2025-12-01 09:40:12 +07:00
|
|
|
|
2025-12-19 00:21:25 +07:00
|
|
|
// Backward compatible variable names (dipakai view lama).
|
|
|
|
|
$data['movementCount'] = $data['movementCount30'] ?? 0;
|
|
|
|
|
$data['disposalCount'] = $data['activeDisposals'] ?? 0;
|
2025-12-01 09:40:12 +07:00
|
|
|
|
2025-12-19 00:21:25 +07:00
|
|
|
return view('pages.dashboards.index', $data);
|
2025-12-01 06:41:22 +07:00
|
|
|
}
|
|
|
|
|
}
|