Search
 
SCRIPT & CODE EXAMPLE
 

PHP

attach multiple files in laravel mailable

public function build()
{
    $email = $this->view('emails.employment_mailview')->subject('Employment Application');

    // $attachments is an array with file paths of attachments
    foreach($attachments as $filePath){
        $email->attach($filePath);
    }
    return $email;
}
Comment

attach one or multiple files laravel mail

<?php
 
namespace AppMail;
 
use AppModelsOrder;
use IlluminateBusQueueable;
use IlluminateMailMailable;
use IlluminateQueueSerializesModels;
 
class OrderShipped extends Mailable
{
    use Queueable, SerializesModels;
 
    /**
     * The order instance.
     *
     * @var AppModelsOrder
     */
    protected $order;
 
    /**
     * Create a new message instance.
     *
     * @param  AppModelsOrder  $order
     * @return void
     */
    public function __construct(Order $order)
    {
        $this->order = $order;
    }
 
    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
      	// if only 1 file
        return $this->view('emails.orders.shipped')->attach($this->order['invoice']);
      
      	// if multiple files then i use this code
        return $this->view('emails.orders.shipped');
      	foreach ($this->order['invoice'] as $file){
            $this->attach($file);
        }
    }
}
// Please do comment if you have a better approach
// We all here to find shorter and faster way to get things done
// Thank you
Comment

PREVIOUS NEXT
Code Example
Php :: laravel permissions package 
Php :: self vs this in php 
Php :: move wordpress to new server 
Php :: relationship in laravel 
Php :: laravel backpack 
Php :: laravel database backup 
Php :: laravel collection only 
Php :: insert into php myqsl 
Php :: laravel redirect problem 
Php :: What’s New in PHP 8 
Php :: Redirect with named route in Laravel 
Php :: php array_search 
Php :: router php 
Php :: laravel 8 cron job 
Php :: strip html tag php 
Php :: inner pages not found yii 
Php :: php javascript dynamic form 
Php :: php echo "<style" posts css text 
Php :: hide category menu from custom post type 
Php :: storefront product search 
Php :: slim disable display error details 
Php :: wordpress set category front end 
Php :: php array associatif move element 
Php :: pass variable in laravel ancher tag laravel 8 
Php :: inject multiple logger symfony 
Php :: No match for argument: phpmyadmin yum 
Php :: cakephp 3 
Php :: php mysql insert record if not exists in table 
Php :: php how to use namespaces 
Php :: requires ext-pcntl 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =