File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -352,7 +352,19 @@ public function buildViewData()
352
352
}
353
353
}
354
354
355
- return $ data ;
355
+ return array_merge ($ data , $ this ->additionalMessageData ());
356
+ }
357
+
358
+ /**
359
+ * Get additional meta-data to pass along with the view data.
360
+ *
361
+ * @return array<string, mixed>
362
+ */
363
+ protected function additionalMessageData (): array
364
+ {
365
+ return [
366
+ '__laravel_mailable ' => get_class ($ this ),
367
+ ];
356
368
}
357
369
358
370
/**
Original file line number Diff line number Diff line change @@ -9,9 +9,13 @@ class MailMailableDataTest extends TestCase
9
9
{
10
10
public function testMailableDataIsNotLost ()
11
11
{
12
- $ testData = ['first_name ' => 'James ' ];
13
-
14
12
$ mailable = new MailableStub ;
13
+
14
+ $ testData = [
15
+ 'first_name ' => 'James ' ,
16
+ '__laravel_mailable ' => get_class ($ mailable ),
17
+ ];
18
+
15
19
$ mailable ->build (function ($ m ) use ($ testData ) {
16
20
$ m ->view ('view ' , $ testData );
17
21
});
Original file line number Diff line number Diff line change @@ -592,6 +592,7 @@ public function testMailableBuildsViewData()
592
592
'first_name ' => 'Taylor ' ,
593
593
'lastName ' => 'Otwell ' ,
594
594
'framework ' => 'Laravel ' ,
595
+ '__laravel_mailable ' => get_class ($ mailable ),
595
596
];
596
597
597
598
$ this ->assertSame ($ expected , $ mailable ->buildViewData ());
You can’t perform that action at this time.
0 commit comments