PHP code example of mailyte / laravel-email-templates

1. Go to this page and download the library: Download mailyte/laravel-email-templates 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/ */

    

mailyte / laravel-email-templates example snippets


Mailyte::template('password-reset')
    ->with(['reset_url' => $url, 'expires_in' => '1 hour'])
    ->send($user);

use Mailyte\EmailTemplates\Facades\Mailyte;

Mailyte::template('email-changed')
    ->with([
        'old_email'  => $user->email,
        'new_email'  => $request->string('email'),
        'cancel_url' => URL::signedRoute('account.email.cancel', $user),
    ])
    ->send($user);        // or ->queue($user)

class AddressChanging extends Mailable
{
    use Queueable, SerializesModels, UsesMailyteTemplate;

    public function __construct(private User $user, private string $newAddress) {}

    protected function mailyte(): TemplateBuilder
    {
        return Mailyte::template('email-changed')->with([...]);
    }
}

'brand' => [
    'logo'   => ['url' => ..., 'dark_url' => ..., 'align' => 'center'],
    'social' => [['name' => 'X', 'url' => 'https://x.com/acme']],
    'footer' => ['address' => ..., 'reason' => ..., 'show_unsubscribe' => null],
],

->theme(['color.primary' => $org->brand_colour, 'logo.url' => $org->logo_url])

Mailyte::blocks()->get('heading')->schema();
Mailyte::blocks()->schemas();          // all 25, keyed by name

'text'  => ['type' => 'text', 'label' => 'Heading', 'group' => 'content', '        'default' => '1', 'options' => ['1', '2', '3']],
// align, color, space_above, space_below
bash
php artisan mailyte:adopt email-changed
bash
php artisan mailyte:publish-template email-changed