Edit File: AcceptStoreUpdateNotify.php
<?php namespace App\Jobs; use App\Models\Setting; use App\Notifications\NotifyUser as Notify; use App\Traits\Firebase; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldBeUnique; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; class AcceptStoreUpdateNotify implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels , Firebase; /** * Create a new job instance. * * @return void */ protected $users , $data; public function __construct($users , $status = 'pending') { $settings = Setting::all()->pluck('value', 'key'); $message_ar = 'تم رفض طلب التعديل الخاص بك'; $message_en = 'Your store update has been refused'; if ($status == 'approved'){ $message_ar = 'تم قبول طلب التعديل الخاص بك'; $message_en = 'Your store update has been approved'; } $this->data = [ 'title_ar' => $settings['site_name'], 'title_en' => $settings['site_name'], 'message_ar' => $message_ar, 'message_en' => $message_en, 'type' => 'admin_approve_update', ]; $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,$android_tokens, $this->data , $user->lang , $user->notify_sound); } }
Back to File Manager