2017 © Pedro Peláez
 

library tuxedo

Simple transactional email classes/templates for Laravel 5.4 mailables

image

tomirons/tuxedo

Simple transactional email classes/templates for Laravel 5.4 mailables

  • Thursday, January 25, 2018
  • by tomirons
  • Repository
  • 2 Watchers
  • 71 Stars
  • 338 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 8 Forks
  • 0 Open issues
  • 10 Versions
  • 9 % Grown

The README.md

Tuxedo

Version License Total Downloads Build Status, (*1)

Tuxedo is an easy way to send transactional emails with Laravel's Mail classes, with the templates already done for you., (*2)

Contents

Installation

1) Run the following command:, (*3)

$ composer require tomirons/tuxedo

2) Open your config/app.php and add the following class to your providers array:, (*4)

TomIrons\Tuxedo\TuxedoServiceProvider::class

3) (Optional) If you would like to edit the templates, run the following command to publish them, (*5)

php artisan vendor:publish --provider=TomIrons\Tuxedo\TuxedoServiceProvider

Classes

There are currently 3 different types of classes you can extend. ActionMailable, AlertMailable, and InvoiceMailable, and each have their own special properties and methods., (*6)

Global Methods

These methods are available in ALL classes. - greeting($greeting) - Sets the greeting for the message. - salutation($salutation) - Sets the salutation for the message. - line($line) - Add a line of text to the message., (*7)

ActionMailable

Methods

  • color($color) - Sets the color of the button. Available options are blue, green, and red.
  • action($text, $url) - Sets the button text and url.
  • success() - Sets the button color to green.
  • error() - Sets the button color to red.
  • info() - Sets the button color to blue.

Example

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use TomIrons\Tuxedo\Mailables\ActionMailable;

class ActionMail extends ActionMailable
{
    use Queueable, SerializesModels;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->greeting('Hello!')
                    ->line('Some line of text to tell you what exactly is going on.')
                    ->action('Click here to do something fun', url('/'))
                    ->line('Some other information to be displayed after the button.')
                    ->salutation('Regards, Example App');
    }
}

Screenshot

Action, (*8)

AlertMailable

Methods

  • info() - Sets the type of the alert to info.
  • warning() - Sets the type of the alert to warning.
  • success() - Sets the type of the alert to success.
  • error() - Sets the type of the alert to error.
  • type($type) - Sets the type of alert, options are info, success, warning, and error.
  • message($message) - Sets the message to display in the alert.

Example

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use TomIrons\Tuxedo\Mailables\AlertMailable;

class AlertMail extends AlertMailable
{
    use Queueable, SerializesModels;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->greeting('Hello!')
                    ->info()
                    ->message('Some text goes here to inform the user')
                    ->line('Some line of text to tell you what exactly is going on.')
                    ->salutation('Regards, Example App');
    }
}

Screenshot

Alert, (*9)

InvoiceMailable

Properties

  • $keys|array - Set which keys to use when looking for an item's name and price.

Methods

  • id($id) - Sets the invoice ID.
  • date($date) - Sets the date to display at the top of the invoice table.
  • due($date) - Sets the due date of the invoice.
  • items($items) - Add an list of items to the invoice. Acceptable variable types are Collection and array.
  • calculate($taxPercent, $shipping) - Calculates the tax and final total, MUST be called after items have been added.

Example

<?php

namespace App\Mail;

use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use TomIrons\Tuxedo\Mailables\InvoiceMailable;

class InvoiceMail extends InvoiceMailable
{
    use Queueable, SerializesModels;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->id(123456)
                    ->greeting('Hi John Doe!')
                    ->date(Carbon::now()->format('l, M j Y \a\t g:i a'))
                    ->due(Carbon::now()->addDays(7)->format('l, M j Y \a\t g:i a'))
                    ->action('Click me to pay', url('/'))
                    ->items([
                        ['product_name' => 'Example Product', 'product_price' => 123.99],
                        ['product_name' => 'Second Product', 'product_price' => 321.99]
                    ])
                    ->calculate(3, 15)
                    ->salutation('Regards, Example App');
    }
}

Screenshot

Invoice, (*10)

License

Tuxedo is open-sourced software licensed under the MIT license, (*11)

The Versions

25/01 2018

1.0.x-dev

1.0.9999999.9999999-dev

Simple transactional email classes/templates for Laravel 5.4 mailables

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tom Irons

20/07 2017

dev-master

9999999-dev

Simple transactional email classes/templates for Laravel mailables

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tom Irons

18/03 2017

dev-develop

dev-develop

Simple transactional email classes/templates for Laravel 5.4 mailables

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tom Irons

17/03 2017

1.0.6

1.0.6.0

Simple transactional email classes/templates for Laravel 5.4 mailables

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tom Irons

04/02 2017

1.0.5

1.0.5.0

Simple transactional email classes/templates for Laravel 5.4 mailables

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tom Irons

01/02 2017

1.0.4

1.0.4.0

Basic transactional mail templates for laravel 5.4

  Sources   Download

MIT

The Requires

 

by Tom Irons

17/11 2016

1.0.3

1.0.3.0

Basic transactional mail templates for laravel 5.3

  Sources   Download

MIT

The Requires

 

by Tom Irons

16/11 2016

1.0.2

1.0.2.0

Basic transactional mail templates for laravel 5.3

  Sources   Download

MIT

The Requires

 

by Tom Irons

15/11 2016

1.0.1

1.0.1.0

Basic transactional mail templates for laravel 5.3

  Sources   Download

MIT

The Requires

 

by Tom Irons

14/11 2016

1.0.0

1.0.0.0

Basic transactional mail templates for laravel 5.3

  Sources   Download

MIT

The Requires

 

by Tom Irons