Files
lpj/app/Http/Controllers/DashboardController.php

37 lines
1.0 KiB
PHP

<?php
namespace Modules\Lpj\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Modules\Lpj\Services\DashboardService;
class DashboardController extends Controller
{
public $dashboardService;
public function __construct(DashboardService $dashboardService)
{
$this->dashboardService = $dashboardService;
}
/**
* Display a listing of the resource.
*/
public function index(Request $request)
{
// nilai default
$start_date = $request->input('start_date', now()->startOfYear()->format('Y-m-d'));
$end_date = $request->input('end_date', now()->format('Y-m-d'));
$validate = $request->validate([
'start_date' => 'nullable|date_format:Y-m-d',
'end_date' => 'nullable|date_format:Y-m-d',
]);
$dashboard = $this->dashboardService->getDashboardData($start_date, $end_date);
// dd($dashboard);
return view('lpj::dashboard.index', compact('dashboard'));
}
}