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(), ]; } public function getPartnerStats(): array { // $partnerAgreementId = Auth::user()->partner_agreement_id; $partnerAgreementId = 1; return [ 'authorization' => Appointment::where('partner_agreement_id', $partnerAgreementId) ->where('status', 'pendente') ->count(), 'scheduling' => Appointment::query() ->leftJoin( 'partner_agreement_services', 'partner_agreement_services.id', '=', 'appointments.partner_agreement_service_id' ) ->where('appointments.partner_agreement_id', $partnerAgreementId) ->where('partner_agreement_services.requires_scheduling', true) ->where('appointments.status', 'pendente') ->count(), //aqui e o count total sem status e sem nada 'completed' => Appointment::where('partner_agreement_id', $partnerAgreementId) ->count(), //status recusado 'not_authorized' => Appointment::where('partner_agreement_id', $partnerAgreementId) ->where('status', 'recusado') ->count(), ]; } }