You've already forked laravel-mail
Constructor changing type hint
This commit is contained in:
21
README.md
21
README.md
@@ -56,17 +56,18 @@ 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 :
|
||||
Next, add a public field '$template_id' to your class, which will be initialized in the constructor :
|
||||
|
||||
```bash
|
||||
public $id;
|
||||
public $template_id;
|
||||
|
||||
/**
|
||||
* @param Integer $id
|
||||
* BMailNotification constructor.
|
||||
* @param string $template_id
|
||||
*/
|
||||
public function __construct(Integer $id)
|
||||
public function __construct(string $template_id)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->template_id = $template_id;
|
||||
}
|
||||
```
|
||||
|
||||
@@ -81,7 +82,7 @@ Then, create a 'toTemplate()' method, in which you specify your template fields
|
||||
```bash
|
||||
public function toTemplate($notifiable)
|
||||
{
|
||||
return (new BMailTemplate($this->id))
|
||||
return (new BMailTemplate($this->template_id))
|
||||
->sender("john.doe@gmail.com", "John OPTIONNAL") OPTIONNAL
|
||||
->replyTo("jean.grey@gmail.com", "Jean OPTIONNAL") OPTIONNAL
|
||||
->recipients([
|
||||
@@ -101,7 +102,13 @@ public function toTemplate($notifiable)
|
||||
}
|
||||
```
|
||||
|
||||
Finally, from your controller, send a notification for a user :
|
||||
Finally, get the template's id :
|
||||
|
||||
```bash
|
||||
Go to https://bluescale.email, Templates tab, click on the template you want to use and copy the template identifier.
|
||||
```
|
||||
|
||||
And from your controller, send a notification for a user :
|
||||
|
||||
```bash
|
||||
User::find('user_id')->notify(new BMailNotification('template_id'));
|
||||
|
||||
@@ -7,7 +7,7 @@ class BMailTemplate implements \JsonSerializable
|
||||
/**
|
||||
* The template for the message
|
||||
*
|
||||
* @var integer
|
||||
* @var string
|
||||
*/
|
||||
public $template;
|
||||
|
||||
@@ -39,7 +39,7 @@ class BMailTemplate implements \JsonSerializable
|
||||
*/
|
||||
public $parameters = [];
|
||||
|
||||
public function __construct(int $template)
|
||||
public function __construct(string $template)
|
||||
{
|
||||
$this->template = $template;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user