Go to file
Loann 840984b8d5 Modifying readme 2020-04-14 18:26:08 +02:00
config Modifying readme and api files 2020-04-09 17:43:19 +02:00
src Creating BMailChannel 2020-04-14 17:24:54 +02:00
.gitignore Adding Guzzle 2020-04-09 10:56:55 +02:00
README.md Modifying readme 2020-04-14 18:26:08 +02:00
composer.json Modifying composer.json 2020-04-09 16:09:23 +02:00
composer.lock Adding Guzzle 2020-04-09 10:56:55 +02:00

README.md

BMail

The BMail package allows you to send email templates with Laravel to the Bluescale API.

Installation

First in your composer.json, add :

"require": {
        "bluescale/laravel-bmail": "dev-master"
}

and

"repositories": [
        {
            "type": "vcs",
            "url": "git@git.bluesquare.io:bluescale/laravel-bmail.git"
        }
]

Next update your package :

composer update bluescale/laravel-bmail

Then publish the assets from your provider :

php artisan vendor:publish

Finally add your API key in the .env :

BMAIL_API_KEY=your_key
BMAIL_API_URL=the_api_url

Usage

First, create a new notification or use an existing one :

php artisan make:notification BMailNotification

Next, add a public field 'id' to your class, which will be initialized in the constructor :

public $id;

/**
 * @param Integer $id
 */
public function __construct(Integer $id)
{
    $this->id = $id;
}

Then, in the via method add :

return [BMailChannel::class];

Then, create a toTemplate method, in which you specify your template fields :

public function toTemplate($notifiable)
{
    return (new BMailTemplate($this->id))
        ->sender("john.doe@gmail.com", "John OPTIONNAL") OPTIONNAL
        ->replyTo("jean.grey@gmail.com", "Jean OPTIONNAL") OPTIONNAL
        ->recipients([
            [
                "elvis@gmail.com", [
                    "name" => "Elvis" OPTIONNAL,
                    "parameters" => ["key" => "value"] OPTIONNAL
                ]
            ],
            [
                "robert@gmail.com"
            ]
        ])
        ->addRecipient("edward@gmail.com")
        ->parameters(["key" => "value", "key" => "value"])
        ->addParameter("key", "value");
}

Finally, send a notification for a user in your controller:

User::find('user_id')->notify(new BMailNotification('template_id'));