| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?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 EducativoConversao1Push extends BasePushNotification
- {
- public function label(): string
- {
- return 'cliente_educ_conversao_1';
- }
- public function title(): string
- {
- return 'Sob Medida funciona assim';
- }
- public function body(): string
- {
- return 'Seu pedido é enviado para várias diaristas disponíveis.';
- }
- 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;
- }
- /**
- * Elegível se:
- * - Nunca agendou via Sob Medida (schedule_type = custom)
- * - OU último agendamento Sob Medida foi há >30 dias
- */
- 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();
- }
- }
|