Hi,
I've make a function to get messages and store it into an array and get attachments from each messages then make array for it also if attachment was exist.
in this case there is a message that has two attachment but when i looping and use dd(); it just show one attachment only.
here is my code:
Code:
public function getTlMessages(){
$mailbox = $this->getTlMailBox();
$messages = $mailbox->getMessages();
$messagelist = [];;
$counter = 0;
foreach ($messages as $message) {
$counter++;
$attachment = $message->getAttachments();
$msg['id'] = $counter;
$msg['gmailid'] = $message->getId();
$msg['number'] = $message->getNumber();
$msg['subject'] = $message->getSubject();
$msg['attachment'] = array();
foreach ($attachment as $attach){
$attachlist['name'] = $attach->getFilename();
$attachlist['subtype'] = $attach->getSubtype();
$msg['attachment'] = $attachlist;
}
$messagelist[] = $msg;
}
dd($messagelist);
return $messages;
}
Here is the result:
it supposed to be two pdf file instead of one in "attachment"