Edit File: AdminAcceptStoreNotify.php
<?php namespace App\Jobs; 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 AdminAcceptStoreNotify implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Firebase; /** * Create a new job instance. * * @return void */ protected $user , $data ; public function __construct($user , $status = 'accepted') { if($status == 'accepted'){ $message_ar = 'تم قبول طلب انضمامك كمتجر'; $message_en = 'Your join request as store has been approved'; $type = 'accept_join' ; }else{ $message_ar = 'تم رفض طلب انضمامك كمتجر'; $message_en = 'Your join request as store has been rejected'; $type = 'refused_join' ; } $this->data = [ 'sender' => auth('admin')->id(), 'sender_name' => auth('admin')->user()->name, 'sender_avatar' => auth('admin')->user()->avatar, 'title_ar' => 'تنبيه اداري', 'title_en' => 'Administrative Notify', 'message_ar' => $message_ar, 'message_en' => $message_en, 'type' => $type , ]; $this->user = $user; } /** * Execute the job. * * @return void */ public function handle() { $ios_tokens = []; $android_tokens = []; $user = $this->user; 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)); info($user->lang); $this->sendNotification($ios_tokens,$android_tokens, $this->data , $user->lang , $user->notify_sound); } } } }
Back to File Manager