PHP code example of escuelademusica / laravel-mjml

1. Go to this page and download the library: Download escuelademusica/laravel-mjml library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

escuelademusica / laravel-mjml example snippets




namespace App\Mail;

use EscuelaDeMusica\MJML\Mail\Mailable;

class CustomMailable extends Mailable
{

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->mjml('view.name',);
    }
}




namespace App\Mail;

use Illuminate\Mail\Mailable;
use EscuelaDeMusica\MJML\InteractsWithMjml;

class SomeEmail extends Mailable
{
    use InteractsWithMjml;

    public function buildView()
    {
        if (isset($this->mjml)) {
            return $this->buildMjmlView();
        }

        return parent::buildView();
    }

    public function build ()
    {
        return $this->mjml('view.name');
    }

    public function render()
    {
        return $this->renderMjml();
    }
}



namespace App\Notifications;

use EscuelaDeMusica\MJML\Mail\Messages\MjmlMessage;

class SomeNotification extends Notification
{
    public function toMail($notifiable)
    {
        return (new MjmlMessage)
            ->subject('Notification Subject')
            ->mjml('notification.name');
    }
}