laravel job queue can’t create or update on database table

  laravel, php

I’m facing a very complicated problem, I want to implement task schedule to send notifications to every driver every 30 seconds,it is working fine and it sends the notifications, now I wanted to create record for every rider get notifcations, on local it works fine but on server it doesn’t create any record!!!

laravel 5.8 env

  QUEUE_CONNECTION=database

/**
 * Create a new job instance.
 *
 * @return void
 */
 public function __construct($order,$uuid)
  {
   $this->order = $order;
   $this->uuid = $uuid;
  }

/**
 * Execute the job.
 *
 * @return void
 */
  public function handle()
   {

 try {

  GetRider::SendNotificationToRider($this->order->id,$this->uuid);

 }catch (ValidatorException $e) {
            return $this->sendError($e->getMessage());
        }
 }

      public function SendNotificationToRider($order_id,$uuid)
        {

                $rider = Rider::where('uuid',$uuid)->first();
                $rider_history = RiderHistory::where('order_number',$order_id)
                            ->where('rider_id',$rider->id)
                            ->first();

                $order = Order::find($order_id);
                $offers = OrderOffer::where('order_number',$order_id)->first();                         

                            if($rider_history == Null) //rider didn't recive any notification
                                    {        
                                      RiderHistory::create([
                                          'order_offer_id' => $offers->id,
                                          'order_number' => $order_id,
                                          'status' => 'pending',
                                          'rider_id' => $rider->id
                                      ]);
                                    }

                     $now = now()->addSeconds(1);
                     foreach ($uuids as $key => $uuid) {
                         dispatch(new RiderNotify($oldOrder,$uuid))->delay($now);
                        $now = $now->addSeconds(3);
                           }

Source: Ask PHP

LEAVE A COMMENT