EducativoConversao1Push.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 EducativoConversao1Push extends BasePushNotification
  9. {
  10. public function label(): string
  11. {
  12. return 'cliente_educ_conversao_1';
  13. }
  14. public function title(): string
  15. {
  16. return 'Sob Medida funciona assim';
  17. }
  18. public function body(): string
  19. {
  20. return 'Seu pedido é enviado para várias diaristas disponíveis.';
  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. /**
  39. * Elegível se:
  40. * - Nunca agendou via Sob Medida (schedule_type = custom)
  41. * - OU último agendamento Sob Medida foi há >30 dias
  42. */
  43. public function eligibleUsers(): Collection
  44. {
  45. return User::whereHas('client')
  46. ->where('registration_complete', true)
  47. ->where(function ($query) {
  48. $query->whereDoesntHave('client.schedules', fn ($q) => $q->where('schedule_type', 'custom'))
  49. ->orWhereDoesntHave('client.schedules', fn ($q) => $q->where('schedule_type', 'custom')
  50. ->where('created_at', '>=', now()->subDays(30)));
  51. })
  52. ->get();
  53. }
  54. }