You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -58,8 +50,6 @@ protected function schedule(Schedule $schedule)
58
50
E-mails are composed the same way mailables are created.
59
51
60
52
```php
61
-
<?php
62
-
63
53
use Stackkit\LaravelDatabaseEmails\Email;
64
54
use Illuminate\Mail\Mailables\Content;
65
55
use Stackkit\LaravelDatabaseEmails\Attachment;
@@ -85,19 +75,14 @@ Email::compose()
85
75
### Sending emails to users in your application
86
76
87
77
```php
88
-
<?php
89
78
Email::compose()
90
79
->user($user)
91
80
->send();
92
81
```
93
82
94
-
By default, the `name` column will be used to set the recipient's name. If you wish to use another column, you should implement the `preferredEmailName` method in your model.
83
+
By default, the `name` column will be used to set the recipient's name. If you wish to use something different, you should implement the `preferredEmailName` method in your model.
95
84
96
85
```php
97
-
<?php
98
-
99
-
use Illuminate\Database\Eloquent\Model;
100
-
101
86
class User extends Model
102
87
{
103
88
public function preferredEmailName(): string
@@ -107,13 +92,9 @@ class User extends Model
107
92
}
108
93
```
109
94
110
-
By default, the `email` column will be used to set the recipient's e-mail address. If you wish to use another column, you should implement the `preferredEmailAddress` method in your model.
95
+
By default, the `email` column will be used to set the recipient's e-mail address. If you wish to use something different, you should implement the `preferredEmailAddress` method in your model.
111
96
112
97
```php
113
-
<?php
114
-
115
-
use Illuminate\Database\Eloquent\Model;
116
-
117
98
class User extends Model
118
99
{
119
100
public function preferredEmailAddress(): string
@@ -123,14 +104,9 @@ class User extends Model
123
104
}
124
105
```
125
106
126
-
By default, the app locale will be used to set the recipient's locale. If you wish to use another column, you should implement the `preferredEmailLocale` method in your model.
107
+
By default, the app locale will be used. If you wish to use something different, you should implement the `preferredEmailLocale` method in your model.
127
108
128
109
```php
129
-
<?php
130
-
131
-
use Illuminate\Database\Eloquent\Model;
132
-
use Illuminate\Contracts\Translation\HasLocalePreference;
133
-
134
110
class User extends Model implements HasLocalePreference
135
111
{
136
112
public function preferredLocale(): string
@@ -145,27 +121,18 @@ class User extends Model implements HasLocalePreference
145
121
You may also pass a mailable to the e-mail composer.
146
122
147
123
```php
148
-
<?php
149
-
150
-
use Stackkit\LaravelDatabaseEmails\Email;
151
-
152
124
Email::compose()
153
125
->mailable(new OrderShipped())
154
126
->send();
155
127
```
156
128
157
129
### Attachments
158
130
159
-
To start attaching files to your e-mails, you may use the `attach` method like you normally would in Laravel.
131
+
To start attaching files to your e-mails, you may use the `attachments` method like you normally would in Laravel.
160
132
However, you will have to use this package's `Attachment` class.
Note: `fromData()` and `fromStorage()` are not supported as the work with raw data.
180
-
</small>
145
+
> [!NOTE]
146
+
> `Attachment::fromData()` and `Attachment::fromStorage()` are not supported as they work with raw data.
181
147
182
148
### Attaching models to e-mails
183
149
184
-
You may attach models to your e-mails.
150
+
You may attach a model to an e-mail. This can be useful to attach a user or another model that belongs to the e-mail.
185
151
186
152
```php
187
-
188
153
Email::compose()
189
154
->model(User::find(1));
190
-
191
155
```
192
156
193
157
### Scheduling
194
158
195
159
You may schedule an e-mail by calling `later` instead of `send`. You must provide a Carbon instance or a strtotime valid date.
196
160
197
161
```php
198
-
<?php
199
-
200
-
use Stackkit\LaravelDatabaseEmails\Email;
201
-
202
162
Email::compose()
203
163
->later('+2 hours');
204
164
```
205
165
206
166
### Queueing e-mails
207
167
208
-
**Important**: When queueing mail using the `queue` function, it is no longer necessary to schedule the `email:send` command. Please make sure it is removed from `app/Console/Kernel.php`.
168
+
> [!IMPORTANT]
169
+
> When queueing mail using the `queue` function, it is no longer necessary to schedule the `email:send` command.
0 commit comments