40 lines
1.1 KiB
PHP
40 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use App\Services\DashboardService;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class DashboardController extends Controller
|
|
{
|
|
protected $title = 'Dashboard Inventory';
|
|
protected $template = 'auth';
|
|
protected $route = 'modules.dashboard.inventory';
|
|
protected $emissionService;
|
|
|
|
public function __construct(DashboardService $emissionService)
|
|
{
|
|
$this->emissionService = $emissionService;
|
|
}
|
|
|
|
public function index(Request $request)
|
|
{
|
|
try {
|
|
$data['inventoryYear'] = $request->input('year', date('Y'));
|
|
|
|
$data['dashboardData'] = $this->emissionService->getDashboardData($data['inventoryYear']);
|
|
$data['title'] = $this->title;
|
|
$data['route'] = $this->route;
|
|
|
|
return view($this->template.'.dashboard', $data);
|
|
|
|
} catch (\Exception $e) {
|
|
Log::error('Error loading dashboard data', [
|
|
'message' => $e->getMessage(),
|
|
'trace' => $e->getTraceAsString(),
|
|
]);
|
|
}
|
|
}
|
|
}
|