Return foreach loop

Posted 1 year ago by GrahamMorbyDev

Hey folks, using a package to get some emails from GMail need to return the results as really an object but an array will work.

So far I'm here :

  //Testing get messages
    public function getMailbox() {
        $messages = LaravelGmail::message()->unread()->preload()->all();
        foreach($messages as $message) {
            $id = $message->getId();
            $date = $message->getDate();
            $from = $message->getFromEmail();
            $email = $message->getPlainTextBody();
        }
        return compact(array('email', 'date', 'from', 'id'));
    }

All I get is one result and there should be four

any ideas

Please sign in or create an account to participate in this conversation.