Package Data | |
---|---|
Maintainer Username: | tomirons |
Maintainer Contact: | tom.irons@hotmail.com (Tom Irons) |
Package Create Date: | 2016-11-10 |
Package Last Update: | 2021-02-26 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-02-09 15:00:16 |
Package Statistics | |
---|---|
Total Downloads: | 2,570 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 94 |
Total Watchers: | 3 |
Total Forks: | 5 |
Total Open Issues: | 0 |
Tuxedo is an easy way to send transactional emails with Laravel's Mail
classes, with the templates already done for you.
$ composer require tomirons/tuxedo
config/app.php
and add the following class to your providers
array:TomIrons\Tuxedo\TuxedoServiceProvider::class
php artisan vendor:publish --provider=TomIrons\Tuxedo\TuxedoServiceProvider
There are currently 3 different types of classes you can extend. ActionMailable
, AlertMailable
, and InvoiceMailable
, and each have their own special properties and 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.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
.<?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');
}
}
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.<?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');
}
}
$keys|array
- Set which keys to use when looking for an item's name and price.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.<?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');
}
}
Tuxedo is open-sourced software licensed under the MIT license