EducativoConversao2Push.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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
  11. {
  12. return 'cliente_educ_conversao_2';
  13. }
  14. public function title(): string
  15. {
  16. return 'Quer mais chances de aceite?';
  17. }
  18. public function body(): string
  19. {
  20. return 'Pedidos Sob Medida aumentam a rapidez na confirmação.';
  21. }
  22. public function target(): PushNotificationTargetEnum
  23. {
  24. return PushNotificationTargetEnum::CLIENTE;
  25. }
  26. public function category(): PushNotificationCategoryEnum
  27. {
  28. return PushNotificationCategoryEnum::EDUCATIVO_CONVERSAO;
  29. }
  30. public function notificationCooldownDays(): int
  31. {
  32. return 28;
  33. }
  34. public function categoryCooldownDays(): int
  35. {
  36. return 14;
  37. }
  38. public function eligibleUsers(): Collection
  39. {
  40. return User::whereHas('client')
  41. ->where('registration_complete', true)
  42. ->where(function ($query) {
  43. $query->whereDoesntHave('client.schedules', fn ($q) => $q->where('schedule_type', 'custom'))
  44. ->orWhereDoesntHave('client.schedules', fn ($q) => $q->where('schedule_type', 'custom')
  45. ->where('created_at', '>=', now()->subDays(30)));
  46. })
  47. ->get();
  48. }
  49. }