Skip to content

Commit f0959ec

Browse files
committed
refactor: Make use of fallback value in config and adapt usage in mailable
1 parent 6f84cb8 commit f0959ec

File tree

2 files changed

+6
-39
lines changed

2 files changed

+6
-39
lines changed

src/App/Mail/ExceptionOccurred.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,6 @@ public function build()
3535
$fromSender = config('exceptions.emailExceptionFrom');
3636
$subject = config('exceptions.emailExceptionSubject');
3737

38-
if ($emailsTo[0] === null) {
39-
$emailsTo = config('exceptions.emailExceptionsToDefault');
40-
}
41-
42-
if ($ccEmails[0] === null) {
43-
$ccEmails = config('exceptions.emailExceptionCCtoDefault');
44-
}
45-
46-
if ($bccEmails[0] === null) {
47-
$bccEmails = config('exceptions.emailExceptionBCCtoDefault');
48-
}
49-
50-
if (! $fromSender) {
51-
$fromSender = config('exceptions.emailExceptionFromDefault');
52-
}
53-
54-
if (! $subject) {
55-
$subject = config('exceptions.emailExceptionSubjectDefault');
56-
}
57-
5838
return $this->from($fromSender)
5939
->to($emailsTo)
6040
->cc($ccEmails)

src/config/exceptions.php

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
| Enable/Disable exception email notifications
1111
|
1212
*/
13-
14-
'emailExceptionEnabled' => env('EMAIL_EXCEPTION_ENABLED'),
15-
'emailExceptionEnabledDefault' => true,
13+
'emailExceptionEnabled' => env('EMAIL_EXCEPTION_ENABLED', true),
1614

1715
/*
1816
|--------------------------------------------------------------------------
@@ -22,9 +20,7 @@
2220
| This is the email your exception will be from.
2321
|
2422
*/
25-
26-
'emailExceptionFrom' => env('EMAIL_EXCEPTION_FROM'),
27-
'emailExceptionFromDefault' => 'email@email.com',
23+
'emailExceptionFrom' => env('EMAIL_EXCEPTION_FROM', ''),
2824

2925
/*
3026
|--------------------------------------------------------------------------
@@ -34,9 +30,7 @@
3430
| This is the email(s) the exceptions will be emailed to.
3531
|
3632
*/
37-
38-
'emailExceptionsTo' => env('EMAIL_EXCEPTION_TO'),
39-
'emailExceptionsToDefault' => 'email@email.com',
33+
'emailExceptionsTo' => env('EMAIL_EXCEPTION_TO', ''),
4034

4135
/*
4236
|--------------------------------------------------------------------------
@@ -46,9 +40,7 @@
4640
| This is the email(s) the exceptions will be CC emailed to.
4741
|
4842
*/
49-
50-
'emailExceptionCCto' => env('EMAIL_EXCEPTION_CC'),
51-
'emailExceptionCCtoDefault' => [],
43+
'emailExceptionCCto' => env('EMAIL_EXCEPTION_CC', []),
5244

5345
/*
5446
|--------------------------------------------------------------------------
@@ -58,9 +50,7 @@
5850
| This is the email(s) the exceptions will be BCC emailed to.
5951
|
6052
*/
61-
62-
'emailExceptionBCCto' => env('EMAIL_EXCEPTION_BCC'),
63-
'emailExceptionBCCtoDefault' => [],
53+
'emailExceptionBCCto' => env('EMAIL_EXCEPTION_BCC', []),
6454

6555
/*
6656
|--------------------------------------------------------------------------
@@ -70,9 +60,7 @@
7060
| This is the subject of the exception email
7161
|
7262
*/
73-
74-
'emailExceptionSubject' => env('EMAIL_EXCEPTION_SUBJECT'),
75-
'emailExceptionSubjectDefault' => 'Error on '.config('app.env'),
63+
'emailExceptionSubject' => env('EMAIL_EXCEPTION_SUBJECT', 'Error on ' . config('app.env')),
7664

7765
/*
7866
|--------------------------------------------------------------------------
@@ -82,7 +70,6 @@
8270
| This is the view that will be used for the email.
8371
|
8472
*/
85-
8673
'emailExceptionView' => 'emails.exception',
8774

8875
];

0 commit comments

Comments
 (0)