Skip to content

Commit 2f3e81a

Browse files
committed
Update mailable template
1 parent 7b1fc99 commit 2f3e81a

File tree

6 files changed

+162
-18
lines changed

6 files changed

+162
-18
lines changed

stubs/mail.stub

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ namespace {{ namespace }};
55
use Illuminate\Bus\Queueable;
66
use Illuminate\Contracts\Queue\ShouldQueue;
77
use Illuminate\Mail\Mailable;
8+
use Illuminate\Mail\Mailables\Content;
9+
use Illuminate\Mail\Mailables\Envelope;
810
use Illuminate\Queue\SerializesModels;
911

1012
class {{ class }} extends Mailable
@@ -14,10 +16,32 @@ class {{ class }} extends Mailable
1416
{{ properties }}
1517

1618
/**
17-
* Build the message.
19+
* Get the message envelope.
1820
*/
19-
public function build(): static
21+
public function envelope(): Envelope
2022
{
21-
return $this->view('{{ view }}');
23+
return new Envelope(
24+
subject: '',
25+
);
26+
}
27+
28+
/**
29+
* Get the message content definition.
30+
*/
31+
public function content(): Content
32+
{
33+
return new Content(
34+
view: '{{ view }}',
35+
);
36+
}
37+
38+
/**
39+
* Get the attachments for the message.
40+
*
41+
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
42+
*/
43+
public function attachments(): array
44+
{
45+
return [];
2246
}
2347
}

tests/fixtures/mailables/added-admin.php

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use Illuminate\Bus\Queueable;
66
use Illuminate\Contracts\Queue\ShouldQueue;
77
use Illuminate\Mail\Mailable;
8+
use Illuminate\Mail\Mailables\Content;
9+
use Illuminate\Mail\Mailables\Envelope;
810
use Illuminate\Queue\SerializesModels;
911

1012
class AddedAdmin extends Mailable
@@ -22,10 +24,32 @@ public function __construct($user)
2224
}
2325

2426
/**
25-
* Build the message.
27+
* Get the message envelope.
2628
*/
27-
public function build(): static
29+
public function envelope(): Envelope
2830
{
29-
return $this->view('emails.admin.added');
31+
return new Envelope(
32+
subject: '',
33+
);
34+
}
35+
36+
/**
37+
* Get the message content definition.
38+
*/
39+
public function content(): Content
40+
{
41+
return new Content(
42+
view: 'emails.admin.added',
43+
);
44+
}
45+
46+
/**
47+
* Get the attachments for the message.
48+
*
49+
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
50+
*/
51+
public function attachments(): array
52+
{
53+
return [];
3054
}
3155
}

tests/fixtures/mailables/mail-configured.php

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use Illuminate\Bus\Queueable;
66
use Illuminate\Contracts\Queue\ShouldQueue;
77
use Illuminate\Mail\Mailable;
8+
use Illuminate\Mail\Mailables\Content;
9+
use Illuminate\Mail\Mailables\Envelope;
810
use Illuminate\Queue\SerializesModels;
911

1012
class ReviewPost extends Mailable
@@ -22,10 +24,32 @@ public function __construct($post)
2224
}
2325

2426
/**
25-
* Build the message.
27+
* Get the message envelope.
2628
*/
27-
public function build(): static
29+
public function envelope(): Envelope
2830
{
29-
return $this->view('emails.review-post');
31+
return new Envelope(
32+
subject: '',
33+
);
34+
}
35+
36+
/**
37+
* Get the message content definition.
38+
*/
39+
public function content(): Content
40+
{
41+
return new Content(
42+
view: 'emails.review-post',
43+
);
44+
}
45+
46+
/**
47+
* Get the attachments for the message.
48+
*
49+
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
50+
*/
51+
public function attachments(): array
52+
{
53+
return [];
3054
}
3155
}

tests/fixtures/mailables/published-post.php

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use Illuminate\Bus\Queueable;
66
use Illuminate\Contracts\Queue\ShouldQueue;
77
use Illuminate\Mail\Mailable;
8+
use Illuminate\Mail\Mailables\Content;
9+
use Illuminate\Mail\Mailables\Envelope;
810
use Illuminate\Queue\SerializesModels;
911

1012
class PublishedPost extends Mailable
@@ -20,10 +22,32 @@ public function __construct()
2022
}
2123

2224
/**
23-
* Build the message.
25+
* Get the message envelope.
2426
*/
25-
public function build(): static
27+
public function envelope(): Envelope
2628
{
27-
return $this->view('emails.published-post');
29+
return new Envelope(
30+
subject: '',
31+
);
32+
}
33+
34+
/**
35+
* Get the message content definition.
36+
*/
37+
public function content(): Content
38+
{
39+
return new Content(
40+
view: 'emails.published-post',
41+
);
42+
}
43+
44+
/**
45+
* Get the attachments for the message.
46+
*
47+
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
48+
*/
49+
public function attachments(): array
50+
{
51+
return [];
2852
}
2953
}

tests/fixtures/mailables/return-type-declarations.php

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use Illuminate\Bus\Queueable;
66
use Illuminate\Contracts\Queue\ShouldQueue;
77
use Illuminate\Mail\Mailable;
8+
use Illuminate\Mail\Mailables\Content;
9+
use Illuminate\Mail\Mailables\Envelope;
810
use Illuminate\Queue\SerializesModels;
911

1012
class ReviewPost extends Mailable
@@ -22,10 +24,32 @@ public function __construct($post)
2224
}
2325

2426
/**
25-
* Build the message.
27+
* Get the message envelope.
2628
*/
27-
public function build(): static
29+
public function envelope(): Envelope
2830
{
29-
return $this->view('emails.review-post');
31+
return new Envelope(
32+
subject: '',
33+
);
34+
}
35+
36+
/**
37+
* Get the message content definition.
38+
*/
39+
public function content(): Content
40+
{
41+
return new Content(
42+
view: 'emails.review-post',
43+
);
44+
}
45+
46+
/**
47+
* Get the attachments for the message.
48+
*
49+
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
50+
*/
51+
public function attachments(): array
52+
{
53+
return [];
3054
}
3155
}

tests/fixtures/mailables/review-post.php

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use Illuminate\Bus\Queueable;
66
use Illuminate\Contracts\Queue\ShouldQueue;
77
use Illuminate\Mail\Mailable;
8+
use Illuminate\Mail\Mailables\Content;
9+
use Illuminate\Mail\Mailables\Envelope;
810
use Illuminate\Queue\SerializesModels;
911

1012
class ReviewPost extends Mailable
@@ -22,10 +24,32 @@ public function __construct($post)
2224
}
2325

2426
/**
25-
* Build the message.
27+
* Get the message envelope.
2628
*/
27-
public function build(): static
29+
public function envelope(): Envelope
2830
{
29-
return $this->view('emails.review-post');
31+
return new Envelope(
32+
subject: '',
33+
);
34+
}
35+
36+
/**
37+
* Get the message content definition.
38+
*/
39+
public function content(): Content
40+
{
41+
return new Content(
42+
view: 'emails.review-post',
43+
);
44+
}
45+
46+
/**
47+
* Get the attachments for the message.
48+
*
49+
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
50+
*/
51+
public function attachments(): array
52+
{
53+
return [];
3054
}
3155
}

0 commit comments

Comments
 (0)