Skip to content

Commit 2e8ca4a

Browse files
Merge pull request #21 from Dudelisius/patch-2
Check for $file in attach and check for $data in attachData
2 parents df1dda2 + 4d4e8a1 commit 2e8ca4a

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

CHANGELOG.md

+30
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,36 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## 4.0.2 - 2019-01-01
8+
9+
**Fixed**
10+
11+
- Fixed regression bug (testing mode)
12+
13+
## 4.0.1 - 2018-12-31
14+
15+
**Added**
16+
17+
- New environment variable `LARAVEL_DATABASE_EMAILS_TESTING_ENABLED` to indicate if testing mode is enabled (*)
18+
19+
**Fixed**
20+
21+
- Fixed issue where Mailables would not be read correctly
22+
- Config file was not cachable (*)
23+
24+
(*) = To be able to cache the config file, change the 'testing' closure to the environment variable as per `laravel-database-emails.php` config file.
25+
26+
## 4.0.0 - 2018-09-15
27+
28+
**Changed**
29+
30+
- Changed package namespace
31+
32+
**Removed**
33+
34+
- Removed resend/retry option entirely
35+
- Removed process time limit
36+
737
## 3.0.3 - 2018-07-24
838

939
**Fixed**

src/EmailComposer.php

+12-4
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,13 @@ public function mailable(Mailable $mailable)
218218
*/
219219
public function attach($file, $options = [])
220220
{
221-
$attachments = $this->hasData('attachments') ? $this->getData('attachments') : [];
221+
$attachments = null;
222222

223-
$attachments[] = compact('file', 'options');
223+
if (! empty($file) || ! is_null($file)) {
224+
$attachments = $this->hasData('attachments') ? $this->getData('attachments') : [];
225+
226+
$attachments[] = compact('file', 'options');
227+
}
224228

225229
return $this->setData('attachments', $attachments);
226230
}
@@ -235,9 +239,13 @@ public function attach($file, $options = [])
235239
*/
236240
public function attachData($data, $name, array $options = [])
237241
{
238-
$attachments = $this->hasData('rawAttachments') ? $this->getData('rawAttachments') : [];
242+
$attachments = null;
239243

240-
$attachments[] = compact('data', 'name', 'options');
244+
if (! empty($data) || ! is_null($data)) {
245+
$attachments = $this->hasData('rawAttachments') ? $this->getData('rawAttachments') : [];
246+
247+
$attachments[] = compact('data', 'name', 'options');
248+
}
241249

242250
return $this->setData('rawAttachments', $attachments);
243251
}

0 commit comments

Comments
 (0)