feat: ✨ re-add the stat before the date result on the dashbaord

This commit is contained in:
Karl Muller 2025-04-28 13:02:05 +00:00
parent 268ce12f07
commit 8118d5a3f9
3 changed files with 31 additions and 0 deletions

View file

@ -20,6 +20,7 @@ class DashboardController extends Controller
public function index(DashboardRequest $request)
{
$statsShop = [];
$adhesion = StatsHelper::getMembershipPercentage();
$statsCustomer = [];
$prevDates = [];
@ -35,6 +36,7 @@ class DashboardController extends Controller
'prevDates',
'statsShop',
'statsCustomer',
'adhesion'
));
}
}

View file

@ -406,4 +406,16 @@ final class StatsHelper
'end' => $start->copy()->subDay()
];
}
/**
* Get the percentage of registered people / people with a generated code
*
* @return integer|float
*/
public static function getMembershipPercentage()
{
$employee = Salarie::count();
$registered = Customers::has('salarie')->count();
return round($registered / $employee * 100, 2);
}
}

View file

@ -5,6 +5,23 @@
<h1 class="h2">Dashboard</h1>
</div>
<div class="container">
<table class="table-responsive table-bordered table">
<thead>
<tr class="table-secondary text-center">
<th scope="col">{{ __('Nombre de salariés') }}</th>
<th scope="col">{{ __('Nombre de salariés inscrits') }}</th>
<th scope="col">{{ __('Taux d\'adhésion') }}</th>
</tr>
</thead>
<tbody>
<tr class="table-light text-bold fw-semibold text-center">
<td>{{ number_format(App\Models\Salarie::count(), 0, ',', ' ') }}</td>
<td>{{ number_format(App\Models\Customers::has('salarie')->count(), 0, ',', ' ') }}</td>
<td>{{ number_format($adhesion, 2, ',', ' ') }} %</td>
</tr>
</tbody>
</table>
<br />
{{-- DATES --}}
<form action="{{ route('bo.dashboard') }}">
<div class="row">