SendPromotionNotification.php 708 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace App\Listeners;
  3. use App\Models\Promotion;
  4. use Illuminate\Contracts\Queue\ShouldQueue;
  5. use Illuminate\Queue\InteractsWithQueue;
  6. use App\Notifications\PromotionNotification;
  7. use Illuminate\Support\Facades\Notification;
  8. class SendPromotionNotification
  9. {
  10. /**
  11. * Create the event listener.
  12. *
  13. * @return void
  14. */
  15. public function __construct()
  16. {
  17. //
  18. }
  19. /**
  20. * Handle the event.
  21. *
  22. * @param object $event
  23. * @return void
  24. */
  25. public function handle($event)
  26. {
  27. $titre = Promotion::where('fin', '<', \Carbon\Carbon::now())->get();
  28. Notification::send($titre, new PromotionNotification($event->titre));
  29. }
  30. }