<?php

namespace App\Notifications\Push\Cliente\SocialProof;

use App\Enums\PushNotificationCategoryEnum;
use App\Enums\PushNotificationTargetEnum;
use App\Models\User;
use App\Notifications\Push\BasePushNotification;
use Illuminate\Database\Eloquent\Collection;

class SocialProof2Push extends BasePushNotification
{
    public function label(): string
    {
        return 'cliente_social_proof_2';
    }

    public function title(): string
    {
        return 'Diaristas bem avaliadas';
    }

    public function body(): string
    {
        return 'Veja profissionais recomendadas perto de você.';
    }

    public function target(): PushNotificationTargetEnum
    {
        return PushNotificationTargetEnum::CLIENTE;
    }

    public function category(): PushNotificationCategoryEnum
    {
        return PushNotificationCategoryEnum::SOCIAL_PROOF;
    }

    public function notificationCooldownDays(): int
    {
        return 28;
    }

    public function categoryCooldownDays(): int
    {
        return 14;
    }

    public function eligibleUsers(): Collection
    {
        return User::whereHas('client')
            ->where('registration_complete', true)
            ->where(function ($query) {
                $query->whereDoesntHave('client.schedules', fn ($q) => $q->where('status', 'finished'))
                    ->orWhereDoesntHave('client.schedules', fn ($q) => $q->where('status', 'finished')
                        ->where('updated_at', '>=', now()->subDays(30)));
            })
            ->get();
    }
}
