Edit File: AdminReplayTicket.php
<?php namespace App\Jobs; use App\Models\Setting; use Illuminate\Bus\Queueable; use App\Traits\Firebase; use Illuminate\Contracts\Queue\ShouldBeUnique; 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 AdminReplayTicket implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Firebase; /** * Create a new job instance. * * @return void */ protected $users,$data; public function __construct($users , $ticket) { $settings = Setting::all()->pluck('value', 'key'); $this->data = [ 'title_ar' => $settings['site_name'], 'title_en' => $settings['site_name'], 'message_ar' => 'لقد تم الرد علي الشكوي خاصتك', 'message_en' => 'Your complaint has been answered', 'type' => 'admin_replay', 'order_id' => $ticket->id ]; $this->users = $users; } /** * Execute the job. * * @return void */ public function handle() { $tokens = []; $user = $this->users; $android_tokens = []; $ios_tokens = []; if ($user->devices->count() > 0) { foreach ($user->devices()->where('device_type' , 'android')->get() as $device) { if($device->user->new_orders_notify=='true') { $android_tokens[] = $device->device_id; } } foreach ($user->devices()->where('device_type' , 'ios')->get() as $device) { if($device->user->new_orders_notify=='true') { $ios_tokens[] = $device->device_id; } } } $user->notify(new Notify($this->data)); $this->sendNotification($ios_tokens , $android_tokens , $this->data); } }
Back to File Manager