42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Bo;
|
|
|
|
use App\Enums\StatsCustomerType;
|
|
use App\Enums\StatsShopType;
|
|
use App\Http\Controllers\Controller;
|
|
use Carbon\Carbon;
|
|
use App\Http\Requests\Bo\DashboardRequest;
|
|
use App\Lib\Helpers\StatsHelper;
|
|
|
|
class DashboardController extends Controller
|
|
{
|
|
/**
|
|
* Dashboard Page
|
|
*
|
|
* @param \App\Http\Requests\Bo\DashboardRequest $request
|
|
* @return \Illuminate\Contracts\View\View
|
|
*/
|
|
public function index(DashboardRequest $request)
|
|
{
|
|
$statsShop = [];
|
|
$adhesion = StatsHelper::getMembershipPercentage();
|
|
$statsCustomer = [];
|
|
$prevDates = [];
|
|
|
|
if ($request->has('start') && $request->has('end')) {
|
|
$start = new Carbon($request->start);
|
|
$end = new Carbon($request->end);
|
|
|
|
$prevDates = StatsHelper::getPreviousPeriod($start, $end);
|
|
$statsShop = StatsHelper::getStats(StatsShopType::toArray(), $start, $end);
|
|
$statsCustomer = StatsHelper::getStats(StatsCustomerType::toArray(), $start, $end);
|
|
}
|
|
return view('bo.dashboard', compact(
|
|
'prevDates',
|
|
'statsShop',
|
|
'statsCustomer',
|
|
'adhesion'
|
|
));
|
|
}
|
|
}
|