ContextualSextaPush.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  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 ContextualSextaPush extends BasePushNotification
  9. {
  10. public function label(): string { return 'cliente_contextual_sexta'; }
  11. public function title(): string { return 'Sexta chegando'; }
  12. public function body(): string { return 'Que tal deixar a casa pronta pro fim de semana?'; }
  13. public function target(): PushNotificationTargetEnum { return PushNotificationTargetEnum::CLIENTE; }
  14. public function category(): PushNotificationCategoryEnum { return PushNotificationCategoryEnum::CONTEXTUAL; }
  15. public function notificationCooldownDays(): int { return 7; }
  16. public function categoryCooldownDays(): int { return 7; }
  17. /** Só retorna usuários se hoje for sexta-feira */
  18. public function eligibleUsers(): Collection
  19. {
  20. if (! now()->isFriday()) {
  21. return new Collection();
  22. }
  23. return User::whereHas('client')
  24. ->where('registration_complete', true)
  25. ->get();
  26. }
  27. }