| 12345678910111213141516171819202122232425 |
- <?php
- namespace App\Services;
- use App\Enums\UserStatusEnum;
- use App\Enums\UserTypeEnum;
- use App\Models\PartnerAgreement;
- use App\Models\User;
- class DashboardService
- {
- public function getStats(): array
- {
- return [
- 'total_associados' => User::where('type', UserTypeEnum::ASSOCIADO)->count(),
- 'associados_ativos' => User::where('type', UserTypeEnum::ASSOCIADO)->where('status', UserStatusEnum::ACTIVE)->count(),
- 'parceiros' => PartnerAgreement::count(),
- 'contratos_a_vencer' => PartnerAgreement::whereNotNull('contract_end')
- ->whereBetween('contract_end', [now()->toDateString(), now()->addDays(30)->toDateString()])
- ->count(),
- 'novos_mes' => PartnerAgreement::whereMonth('created_at', now()->month)->whereYear('created_at', now()->year)->count(),
- 'associados_pendentes' => User::where('type', UserTypeEnum::ASSOCIADO)->where('status', UserStatusEnum::PENDING)->count(),
- ];
- }
- }
|