2020-11-03 15:53:07 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Bo;
|
|
|
|
|
|
2025-01-13 15:43:42 +01:00
|
|
|
use App\Enums\StatsCustomerType;
|
|
|
|
|
use App\Enums\StatsShopType;
|
2020-11-03 15:53:07 +01:00
|
|
|
use App\Http\Controllers\Controller;
|
2023-08-30 08:03:04 +00:00
|
|
|
use Carbon\Carbon;
|
|
|
|
|
use App\Http\Requests\Bo\DashboardRequest;
|
|
|
|
|
use App\Lib\Helpers\StatsHelper;
|
2020-11-03 15:53:07 +01:00
|
|
|
|
|
|
|
|
class DashboardController extends Controller
|
|
|
|
|
{
|
2022-09-08 13:02:16 +02:00
|
|
|
/**
|
|
|
|
|
* Dashboard Page
|
|
|
|
|
*
|
2023-08-30 08:03:04 +00:00
|
|
|
* @param \App\Http\Requests\Bo\DashboardRequest $request
|
2022-09-08 13:02:16 +02:00
|
|
|
* @return \Illuminate\Contracts\View\View
|
|
|
|
|
*/
|
2023-08-30 08:03:04 +00:00
|
|
|
public function index(DashboardRequest $request)
|
2020-11-03 15:53:07 +01:00
|
|
|
{
|
2025-01-13 15:43:42 +01:00
|
|
|
$statsShop = [];
|
2025-04-28 13:02:05 +00:00
|
|
|
$adhesion = StatsHelper::getMembershipPercentage();
|
2025-01-13 15:43:42 +01:00
|
|
|
$statsCustomer = [];
|
|
|
|
|
$prevDates = [];
|
2023-08-30 08:03:04 +00:00
|
|
|
|
|
|
|
|
if ($request->has('start') && $request->has('end')) {
|
2025-01-13 15:43:42 +01:00
|
|
|
$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);
|
2023-08-30 08:03:04 +00:00
|
|
|
}
|
2025-01-13 15:43:42 +01:00
|
|
|
return view('bo.dashboard', compact(
|
|
|
|
|
'prevDates',
|
|
|
|
|
'statsShop',
|
|
|
|
|
'statsCustomer',
|
2025-04-28 13:02:05 +00:00
|
|
|
'adhesion'
|
2025-01-13 15:43:42 +01:00
|
|
|
));
|
2020-11-03 15:53:07 +01:00
|
|
|
}
|
|
|
|
|
}
|