You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
855 B

4 years ago
  1. <?php
  2. namespace App\Listeners;
  3. use App\Models\User;
  4. use App\Models\Business;
  5. use Illuminate\Support\Arr;
  6. use App\Events\BusinessUpdate;
  7. use App\Events\BusinessUserCreate;
  8. use App\Notifications\DBNotification;
  9. use App\Notifications\MailNotification;
  10. use Illuminate\Queue\InteractsWithQueue;
  11. use Illuminate\Contracts\Queue\ShouldQueue;
  12. use Illuminate\Support\Facades\Notification;
  13. class BusinessUpdateListener
  14. {
  15. public function handle(BusinessUpdate $event)
  16. {
  17. $payload = $event->message;
  18. $wallet = $payload?->data?->diff?->wallet;
  19. $owners = Business::findOrFail($payload->business)->owners;
  20. $message = ['body' => 'Test'];
  21. if ($wallet < 0) {
  22. Notification::send($owners, new MailNotification($message));
  23. Notification::send($owners, new DBNotification($message));
  24. }
  25. }
  26. }