Modifying readme
This commit is contained in:
parent
a59eca7dc4
commit
840984b8d5
39
README.md
39
README.md
|
@ -1,6 +1,6 @@
|
||||||
# BMail
|
# BMail
|
||||||
|
|
||||||
The BMail package allows you to send email templates on Laravel to the Bluescale API.
|
The BMail package allows you to send email templates with Laravel to the Bluescale API.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
@ -44,8 +44,38 @@ BMAIL_API_URL=the_api_url
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
First, create a new notification or use an existing one :
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$template = (new BMailTemplate("** template_id **"))
|
php artisan make:notification BMailNotification
|
||||||
|
```
|
||||||
|
|
||||||
|
Next, add a public field 'id' to your class, which will be initialized in the constructor :
|
||||||
|
|
||||||
|
```bash
|
||||||
|
public $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Integer $id
|
||||||
|
*/
|
||||||
|
public function __construct(Integer $id)
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, in the via method add :
|
||||||
|
|
||||||
|
```bash
|
||||||
|
return [BMailChannel::class];
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, create a toTemplate method, in which you specify your template fields :
|
||||||
|
|
||||||
|
```bash
|
||||||
|
public function toTemplate($notifiable)
|
||||||
|
{
|
||||||
|
return (new BMailTemplate($this->id))
|
||||||
->sender("john.doe@gmail.com", "John OPTIONNAL") OPTIONNAL
|
->sender("john.doe@gmail.com", "John OPTIONNAL") OPTIONNAL
|
||||||
->replyTo("jean.grey@gmail.com", "Jean OPTIONNAL") OPTIONNAL
|
->replyTo("jean.grey@gmail.com", "Jean OPTIONNAL") OPTIONNAL
|
||||||
->recipients([
|
->recipients([
|
||||||
|
@ -62,10 +92,13 @@ $template = (new BMailTemplate("** template_id **"))
|
||||||
->addRecipient("edward@gmail.com")
|
->addRecipient("edward@gmail.com")
|
||||||
->parameters(["key" => "value", "key" => "value"])
|
->parameters(["key" => "value", "key" => "value"])
|
||||||
->addParameter("key", "value");
|
->addParameter("key", "value");
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Finally, send a notification for a user in your controller:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
return (new BMailApi(config("bmail.api_key")))->send($template);
|
User::find('user_id')->notify(new BMailNotification('template_id'));
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue