SendOrderPusherNotification.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace App\Jobs;
  3. use Illuminate\Bus\Queueable;
  4. use Illuminate\Contracts\Queue\ShouldQueue;
  5. use Illuminate\Foundation\Bus\Dispatchable;
  6. use Illuminate\Queue\InteractsWithQueue;
  7. use Illuminate\Queue\SerializesModels;
  8. use Pusher\Pusher;
  9. class SendOrderPusherNotification implements ShouldQueue
  10. {
  11. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  12. private $pusherData;
  13. /**
  14. * Create a new job instance.
  15. *
  16. * @return void
  17. */
  18. public function __construct($pusherData)
  19. {
  20. $this->pusherData = $pusherData;
  21. }
  22. /**
  23. * Execute the job.
  24. *
  25. * @return void
  26. */
  27. public function handle()
  28. {
  29. //
  30. $options = array(
  31. 'cluster' => env('PUSHER_APP_CLUSTER'),
  32. 'encrypted' => true
  33. );
  34. $pusher = new Pusher(
  35. env('PUSHER_APP_KEY'),
  36. env('PUSHER_APP_SECRET'),
  37. env('PUSHER_APP_ID'),
  38. $options
  39. );
  40. $pusher->trigger(env('PUHER_APP_CHANNEL'), 'App\\Events\\OrderNotification', $this->pusherData);
  41. }
  42. }