Using Mailables Markdown Laravel

Just to make it short this is just to make mailables markdown template, which has been useful to me.

php artisan make:mail CreateOrder --markdown=mail.orders.created

File app.mail.createOrder

public function __construct($content)
{
$this->content = $content;
}

public function build()
{
return $this->from('[email protected]')
->subject('Title')
->markdown('mail.orders.created')
->with('content',$this->content);
}

File - views.mail.orders.created

@component('mail::message')
{{$content['title']}}
{!!$content['body']!!}

@component('mail::button', ['url' => $content['url']])
{{$content['button']}}
@endcomponent

Thank you,

{{ config('app.name') }}
@endcomponent

File - app.Http.Controllers.any

use App\Mail\CreateOrder;
use Mail;

$content = [
'title'=> $args['booking_number'],
'body'=> 'Body',
'button' => 'Action Text',
'url' => url('anywhere')
];
$receiverAddress = 'name@domain';
Mail::to($receiverAddress)->send(new CreateOrder($content));

Subscribe to You Live What You Learn

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
[email protected]
Subscribe