74 lines
2.5 KiB
PHP
74 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Services\DashboardMitigationService;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class DashboardMitigasiController extends Controller
|
|
{
|
|
protected $title = 'Dashboard Mitigasi';
|
|
// protected $template = 'modules.dashboard.mitigasi';
|
|
protected $route = 'modules.dashboard.mitigasi';
|
|
|
|
protected DashboardMitigationService $mitigationService;
|
|
|
|
public function __construct(DashboardMitigationService $mitigationService)
|
|
{
|
|
$this->mitigationService = $mitigationService;
|
|
}
|
|
|
|
|
|
public function aksi(Request $request)
|
|
{
|
|
$year = (int) $request->input('mitigationYear', date('Y'));
|
|
|
|
try {
|
|
$dashboardData = $this->mitigationService->getDashboardData($year);
|
|
return view('auth.dashboard-mitigation-aksi', [
|
|
'title' => $this->title,
|
|
'route' => $this->route,
|
|
'stats' => $dashboardData['stats'],
|
|
'charts' => $dashboardData['charts'],
|
|
'today' => Carbon::today()->translatedFormat('d F Y'),
|
|
]);
|
|
} catch(\Exception $e) {
|
|
Log::error('Error loading aksi mitigasi dashboard', [
|
|
'message' => $e->getMessage(),
|
|
'trace' => $e->getTraceAsString(),
|
|
]);
|
|
|
|
return back()->withErrors(['error' => 'Gagal memuat dashboard aksi mitigasi.']);
|
|
}
|
|
}
|
|
|
|
public function index(Request $request)
|
|
{
|
|
$year = (int) $request->input('mitigationYear', date('Y'));
|
|
|
|
try {
|
|
$dashboardData = $this->mitigationService->getDashboardData($year);
|
|
|
|
return view('auth.dashboard-mitigation', [
|
|
'title' => $this->title,
|
|
'route' => $this->route,
|
|
'selectedYear' => $dashboardData['mitigationYear'],
|
|
'tableData' => $dashboardData['tableData'],
|
|
'barData' => $dashboardData['barData'],
|
|
'budgetData' => $dashboardData['budgetData'],
|
|
'realisasiData' => $dashboardData['realisasiData'],
|
|
]);
|
|
} catch(\Exception $e) {
|
|
Log::error('Error loading dashboard mitigation data', [
|
|
'message' => $e->getMessage(),
|
|
'trace' => $e->getTraceAsString(),
|
|
]);
|
|
|
|
// optional: kasih feedback ke user biar nggak blank
|
|
return back()->withErrors(['error' => 'Gagal memuat dashboard mitigasi.']);
|
|
}
|
|
}
|
|
}
|