| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace App\Jobs;
- use App\Helpers\DateHelper;
- use App\Models\Order;
- use App\Models\Schedule;
- use App\Notifications\FireBaseNotification;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Foundation\Queue\Queueable;
- class NotifyOrderInScheduleJob implements ShouldQueue
- {
- use Queueable;
- /**
- * Create a new job instance.
- */
- public function __construct(
- private readonly Schedule $schedule,
- )
- {}
- /**
- * Execute the job.
- */
- public function handle(): void
- {
- $title = 'График монтажа';
- $body = 'Адрес ' . $this->schedule->object_address . ' поставлен на монтаж с ' . DateHelper::getHumanDate($this->schedule->installation_date, true);
- if(!is_null($this->schedule->brigadier->token_fcm)) {
- $this->schedule->brigadier->notify(new FireBaseNotification($title, $body));
- }
- if(!is_null($this->schedule->order_id)) {
- $order = Order::query()->where('id', $this->schedule->order_id)->first();
- if(!is_null($order->user->token_fcm)) {
- $order->user->notify(new FireBaseNotification($title, $body));
- }
- }
- }
- }
|