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']}}
@endcomponentThank 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));