Edit File: NewReviewNotify.php
<?php namespace App\Jobs; use App\Traits\Firebase; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use App\Notifications\NotifyUser as Notify ; class NewReviewNotify implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Firebase; /** * Create a new job instance. * * @return void */ protected $users, $data; public function __construct($users,$order_id) { $user = auth('api')->user(); $this->data = [ 'sender' => $user->id, 'sender_name' => $user->name, 'sender_avatar' => $user->AvatarPath, 'order_id'=>$order_id, 'title_ar' => $user->name .' لديك تقييم جديد من ' , 'title_en' => 'you have new review from '.$user->name , 'message_ar' => ' قام ' . $user->name . ' بتقييمك ', 'message_en' =>$user->name . 'has been rated you', 'type' => 'new_review' , ]; $this->users = $users; } /** * Execute the job. * * @return void */ public function handle() { $ios_tokens = []; $android_tokens = []; $user = $this->users; if (isset($user->devices)) { if ($user->devices->count() > 0) { foreach ($user->devices()->where('device_type','ios')->get() as $device) { if($device->user->new_orders_notify=='true'){ $ios_tokens[] = $device->device_id; } } foreach ($user->devices()->where('device_type','android')->get() as $device) { if($device->user->new_orders_notify=='true'){ $android_tokens[] = $device->device_id; } } $user->notify(new Notify($this->data)); $this->sendNotification($ios_tokens, $this->data , 'ios'); $this->sendNotification($android_tokens, $this->data , 'android'); } } } }
Back to File Manager