EducativoConversao2Push.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace App\Notifications\Push\Cliente\EducativoConversao;
  3. use App\Enums\PushNotificationCategoryEnum;
  4. use App\Enums\PushNotificationTargetEnum;
  5. use App\Models\User;
  6. use App\Notifications\Push\BasePushNotification;
  7. use Illuminate\Database\Eloquent\Collection;
  8. class EducativoConversao2Push extends BasePushNotification
  9. {
  10. public function label(): string { return 'cliente_educ_conversao_2'; }
  11. public function title(): string { return 'Quer mais chances de aceite?'; }
  12. public function body(): string { return 'Pedidos Sob Medida aumentam a rapidez na confirmação.'; }
  13. public function target(): PushNotificationTargetEnum { return PushNotificationTargetEnum::CLIENTE; }
  14. public function category(): PushNotificationCategoryEnum { return PushNotificationCategoryEnum::EDUCATIVO_CONVERSAO; }
  15. public function notificationCooldownDays(): int { return 28; }
  16. public function categoryCooldownDays(): int { return 14; }
  17. public function eligibleUsers(): Collection
  18. {
  19. return User::whereHas('client')
  20. ->where('registration_complete', true)
  21. ->where(function ($query) {
  22. $query->whereDoesntHave('client.schedules', fn ($q) => $q->where('schedule_type', 'custom'))
  23. ->orWhereDoesntHave('client.schedules', fn ($q) => $q->where('schedule_type', 'custom')
  24. ->where('created_at', '>=', now()->subDays(30)));
  25. })
  26. ->get();
  27. }
  28. }