Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tomirons/tuxedo

Simple transactional email classes/templates for Laravel 5 mailables
https://github.com/tomirons/tuxedo

laravel php tuxedo

Last synced: 12 days ago
JSON representation

Simple transactional email classes/templates for Laravel 5 mailables

Awesome Lists containing this project

README

        

# Tuxedo
[![Version](https://img.shields.io/packagist/v/tomirons/tuxedo.svg)](https://packagist.org/packages/tomirons/tuxedo)
[![License](https://poser.pugx.org/tomirons/tuxedo/license.svg)](https://packagist.org/packages/tomirons/tuxedo)
[![Total Downloads](https://img.shields.io/packagist/dt/tomirons/tuxedo.svg)](https://packagist.org/packages/tomirons/tuxedo)
[![Build Status](https://travis-ci.org/tomirons/tuxedo.svg?branch=master)](https://travis-ci.org/tomirons/tuxedo)

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

## Contents

- [Installation](#installation)
- [Classes](#classes)
- [ActionMailable](#actionmailable)
- [AlertMailable](#alertmailable)
- [InvoiceMailable](#invoicemailable)
- [License](#license)

## Installation
1) Run the following command:

````shell
$ composer require tomirons/tuxedo
````

2) Open your `config/app.php` and add the following class to your `providers` array:

````php
TomIrons\Tuxedo\TuxedoServiceProvider::class
````

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

````shell
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.

#### 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.

### 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
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](https://i.imgur.com/1VHPO0c.png)

### 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
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](https://i.imgur.com/ckOLIxT.png)

### 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
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](https://i.imgur.com/d5S8gJl.png)

## License
Tuxedo is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)