<?php

namespace App\Http\Controllers;

use App\Models\TransaksiParkir;
use Carbon\Carbon;
use Illuminate\Http\Request;

class HomeController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Contracts\Support\Renderable
     */
    public function index()
    {
        $dateNow = Carbon::now()->format('Y-m-d');
        $data = TransaksiParkir::get();

        $VeriTrans = TransaksiParkir::where('veri_check', 2)->whereDate('veri_date', $dateNow)->count();
        $incidenTrans = TransaksiParkir::where('veri_check', 0)->whereDate('veri_date', $dateNow)->count();
        $pendingTrans = TransaksiParkir::where('veri_check', 1)->whereDate('veri_date', $dateNow)->count();
        $inSite = TransaksiParkir::where('status', 1)->count();
        // $VeriTrans = $data->where('veri_check', 2)->whereDate('veri_date', $dateNow)->count();
        // $incidenTrans = $data->where('veri_check', 0)->whereDate('veri_date', $dateNow)->count();
        // $pendingTrans = $data->where('veri_check', 1)->whereDate('veri_date', $dateNow)->count();
        // $inSite = $data->where('status',1)->count();
        
        // dd($dateNow, $VeriTrans,$incidenTrans);
        return view('home', compact('VeriTrans','incidenTrans', 'pendingTrans','inSite'));
    }
}
