<?php

namespace App\Http\Controllers\Admin;

use App\Charts\Shop\Order;
use App\Http\Controllers\Controller;
use App\Repositories\Shop\Dashboards;
use Carbon\Carbon;
use Illuminate\Http\Request;

class HomeController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth');
    }

    public function index(Request $request, $period = false)
    {
        $start = $request->input('start') ?? Carbon::now()->subMonths(12)->startOfMonth();
        $end = $request->input('end') ?? Carbon::now();

        $data = Dashboards::getStats($start, $end);
        $data['chart'] = Order::getMonthly();

        // dump($data);
        // exit;
        return view('Admin.Shop.Dashboard.index', $data);
    }
}
