NotifyManagerNewOrderJob.php 784 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace App\Jobs;
  3. use App\Models\Order;
  4. use App\Notifications\FireBaseNotification;
  5. use Illuminate\Contracts\Queue\ShouldQueue;
  6. use Illuminate\Foundation\Queue\Queueable;
  7. class NotifyManagerNewOrderJob implements ShouldQueue
  8. {
  9. use Queueable;
  10. /**
  11. * Create a new job instance.
  12. */
  13. public function __construct( private readonly Order $order )
  14. {}
  15. /**
  16. * Execute the job.
  17. */
  18. public function handle(): void
  19. {
  20. $title = 'Новая площадка!';
  21. $body = 'Площадка ' . $this->order->common_name . '. Статус: ' . $this->order->orderStatus->name;
  22. if(!is_null($this->order->user->token_fcm)) {
  23. $this->order->user->notify(new FireBaseNotification($title, $body));
  24. }
  25. }
  26. }