<?php

namespace App\Notifications\Push\Cliente\Recorrencia;

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

class Recorrencia2Push extends BasePushNotification
{
    public function label(): string
    {
        return 'cliente_recorrencia_2';
    }

    public function title(): string
    {
        return 'Rotina em dia';
    }

    public function body(): string
    {
        return 'Que tal agendar sua próxima diária?';
    }

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

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

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