src/Messages/Receiver.php
private function boot()
    {
        $messages = [];
        foreach ($this->messaging as $message) {
            $receiveMessage = new ReceiveMessage(Arr::get($message, 'recipient.id'), Arr::get($message, 'sender.id'));
            // is payload
            if (Arr::has($message, 'postback.payload') || Arr::has($message, 'message.quick_reply.payload')) {
                $receiveMessage
                    ->setMessage(Arr::get($message, 'message.text'))
                    ->setReferral(Arr::get($message, 'postback.referral', []))
                    ->setPostback(Arr::get(
                        $message,
                        'postback.payload',
                        Arr::get(
                            $message,
                            'message.quick_reply.payload'
                        )
                    ))
                    ->setPayload(true);
            } else {
                $receiveMessage
                    ->setMessage(Arr::get($message, 'message.text'))
                    ->setReferral(Arr::get($message, 'referral', []))
                    ->setSkip(
                        Arr::has($message, 'delivery') ||
                        Arr::has($message, 'message.is_echo') ||
                        (!Arr::has($message, 'message.text') && !Arr::has($message, 'message.attachments') && !Arr::has($message, 'referral'))
                    )
                    ->setAttachments(Arr::get($message, 'message.attachments', []))
                    ->setNlp(Arr::get($message, 'message.nlp', []));
            }

            $messages[] = $receiveMessage;
        }

        $this->collection = new ReceiveMessageCollection($messages);

        if ($this->filterSkip) {
            $this->collection = $this->collection->filterSkip();
        }
    }
private function boot()
    {
        $messages = [];
        foreach ($this->messaging as $message) {
            $receiveMessage = new ReceiveMessage(Arr::get($message, 'recipient.id'), Arr::get($message, 'sender.id'));
            // is payload
            if (Arr::has($message, 'postback.payload') || Arr::has($message, 'message.quick_reply.payload')) {
                $receiveMessage
                    ->setMessage(Arr::get($message, 'message.text'))
                    ->setReferral(Arr::get($message, 'postback.referral', []))
                    ->setPostback(Arr::get(
                        $message,
                        'postback.payload',
                        Arr::get(
                            $message,
                            'message.quick_reply.payload'
                        )
                    ))
                    ->setPayload(true);
            } else {
                $receiveMessage
                    ->setMessage(Arr::get($message, 'message.text'))
                    ->setReferral(Arr::get($message, 'referral', []))
                    ->setSkip(
                        Arr::has($message, 'delivery') ||
                        Arr::has($message, 'message.is_echo') ||
                        (!Arr::has($message, 'message.text') && !Arr::has($message, 'message.attachments') && !Arr::has($message, 'referral'))
                    )
                    ->setAttachments(Arr::get($message, 'message.attachments', []))
                    ->setNlp(Arr::get($message, 'message.nlp', []));
            }

            $messages[] = $receiveMessage;
        }

        $this->collection = new ReceiveMessageCollection($messages);

        if ($this->filterSkip) {
            $this->collection = $this->collection->filterSkip();
        }
    }
private function boot ( ) { $ messages = [ ] ; foreach ( $ this -> messaging as $ message ) { $ receiveMessage = new ReceiveMessage ( Arr :: get ( $ message , 'recipient.id' ) , Arr :: get ( $ message , 'sender.id' ) ) ; // is payload if ( Arr :: has ( $ message , 'postback.payload' ) || Arr :: has ( $ message , 'message.quick_reply.payload' ) ) { $ receiveMessage -> setMessage ( Arr :: get ( $ message , 'message.text' ) ) -> setReferral ( Arr :: get ( $ message , 'postback.referral' , [ ] ) ) -> setPostback ( Arr :: get ( $ message , 'postback.payload' , Arr :: get ( $ message , 'message.quick_reply.payload' ) ) ) -> setPayload ( true ) ; } else { $ receiveMessage -> setMessage ( Arr :: get ( $ message , 'message.text' ) ) -> setReferral ( Arr :: get ( $ message , 'referral' , [ ] ) ) -> setSkip ( Arr :: has ( $ message , 'delivery' ) || Arr :: has ( $ message , 'message.is_echo' ) || ( ! Arr :: has ( $ message , 'message.text' ) && ! Arr :: has ( $ message , 'message.attachments' ) && ! Arr :: has ( $ message , 'referral' ) ) ) -> setAttachments ( Arr :: get ( $ message , 'message.attachments' , [ ] ) ) -> setNlp ( Arr :: get ( $ message , 'message.nlp' , [ ] ) ) ; } $ messages [ ] = $ receiveMessage ; } $ this -> collection = new ReceiveMessageCollection ( $ messages ) ; if ( $ this -> filterSkip ) { $ this -> collection = $ this -> collection -> filterSkip ( ) ; } }
Boot to reorganize messages
Boot to reorganize messages