54 lines
1.6 KiB
PHP
54 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Controllers\Bo;
|
|
|
|
use App\Contracts\Directories\EmployeeDirectory;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\Bo\Dashboard\DashboardRequest;
|
|
use App\Services\StatsService;
|
|
use Domain\Enums\StatsCustomerType;
|
|
use Domain\Enums\StatsShopType;
|
|
|
|
class DashboardController extends Controller
|
|
{
|
|
public function __construct(
|
|
private readonly EmployeeDirectory $employeeDirectory,
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* Dashboard Page
|
|
*
|
|
* @return \Illuminate\Contracts\View\View
|
|
*/
|
|
public function index(DashboardRequest $request, StatsService $statsService)
|
|
{
|
|
$statsShop = [];
|
|
$adhesion = $statsService->getMembershipPercentage();
|
|
$statsCustomer = [];
|
|
$prevDates = [];
|
|
|
|
$start = $request->getStart();
|
|
$end = $request->getEnd();
|
|
|
|
if ($start && $end) {
|
|
$prevDates = $statsService->getPreviousPeriod($start, $end);
|
|
$statsShop = $statsService->getStats(StatsShopType::cases(), $start, $end);
|
|
$statsCustomer = $statsService->getStats(StatsCustomerType::cases(), $start, $end);
|
|
}
|
|
|
|
$employeeCount = $this->employeeDirectory->countActiveEmployees();
|
|
$customersLinkedToEmployeeCount = $this->employeeDirectory->countActiveRegisteredEmployees();
|
|
|
|
return view('bo.dashboard', compact(
|
|
'prevDates',
|
|
'statsShop',
|
|
'statsCustomer',
|
|
'adhesion',
|
|
'employeeCount',
|
|
'customersLinkedToEmployeeCount',
|
|
));
|
|
}
|
|
}
|