<?php

namespace App\Notifications\Push\Cliente\EducativoConversao;

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

class EducativoConversao2Push extends BasePushNotification
{
    public function label(): string
    {
        return 'cliente_educ_conversao_2';
    }

    public function title(): string
    {
        return 'Quer mais chances de aceite?';
    }

    public function body(): string
    {
        return 'Pedidos Sob Medida aumentam a rapidez na confirmação.';
    }

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

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

    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('schedule_type', 'custom'))
                    ->orWhereDoesntHave('client.schedules', fn ($q) => $q->where('schedule_type', 'custom')
                        ->where('created_at', '>=', now()->subDays(30)));
            })
            ->get();
    }
}
