ContextualSegundaPush.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace App\Notifications\Push\Cliente\Contextual;
  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 ContextualSegundaPush extends BasePushNotification
  9. {
  10. public function label(): string
  11. {
  12. return 'cliente_contextual_segunda';
  13. }
  14. public function title(): string
  15. {
  16. return 'Segunda organizada';
  17. }
  18. public function body(): string
  19. {
  20. return 'Comece a semana com a casa limpa.';
  21. }
  22. public function target(): PushNotificationTargetEnum
  23. {
  24. return PushNotificationTargetEnum::CLIENTE;
  25. }
  26. public function category(): PushNotificationCategoryEnum
  27. {
  28. return PushNotificationCategoryEnum::CONTEXTUAL;
  29. }
  30. public function notificationCooldownDays(): int
  31. {
  32. return 7;
  33. }
  34. public function categoryCooldownDays(): int
  35. {
  36. return 7;
  37. }
  38. /** Só retorna usuários se hoje for segunda-feira */
  39. public function eligibleUsers(): Collection
  40. {
  41. if (! now()->isMonday()) {
  42. return new Collection;
  43. }
  44. return User::whereHas('client')
  45. ->where('registration_complete', true)
  46. ->get();
  47. }
  48. }