コード例 #1
0
 protected function processMessages($wa)
 {
     $outbounds = Outbound::whatsapp($this->argument('number'))->queued()->get();
     foreach ($outbounds as $outbound) {
         $to = $outbound->to;
         // todo // add or update wa-contact
         // $wa->sendPresenceSubscription($to);
         $wa->sendMessageComposing($to);
         $wa->sendMessagePaused($to);
         $message_id = $wa->sendMessage($to, $outbound->text);
         $outbound_chunk = new OutboundChunk();
         $outbound_chunk->outbound_id = $outbound->id;
         $outbound_chunk->message_id = $message_id;
         $outbound_chunk->status_code = 0;
         $outbound_chunk->price = 0.0;
         $outbound_chunk->save();
         $outbound->status = 'sent';
         $outbound->save();
         $wa->pollMessage();
     }
 }