Skip to content

Commit b016260

Browse files
committed
Migrate User Emails to MD
1 parent 09e6ea2 commit b016260

28 files changed

+482
-468
lines changed

app/Mail/Purge/FirstWarning.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function envelope(): Envelope
5050
public function content(): Content
5151
{
5252
return new Content(
53-
view: 'emails.purge.first.html',
53+
markdown: 'emails.purge.first.md',
5454
);
5555
}
5656

app/Mail/Purge/SecondWarning.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function envelope(): Envelope
5050
public function content(): Content
5151
{
5252
return new Content(
53-
view: 'emails.purge.second.html',
53+
markdown: 'emails.purge.second.md',
5454
);
5555
}
5656

app/Mail/Subscription/User/CancelledUserSubscriptionMail.php

+20-9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
use App\Models\User;
66
use Illuminate\Bus\Queueable;
77
use Illuminate\Mail\Mailable;
8+
use Illuminate\Mail\Mailables\Address;
9+
use Illuminate\Mail\Mailables\Content;
10+
use Illuminate\Mail\Mailables\Envelope;
811
use Illuminate\Queue\SerializesModels;
912

1013
class CancelledUserSubscriptionMail extends Mailable
@@ -28,16 +31,24 @@ public function __construct(User $user)
2831
}
2932

3033
/**
31-
* Build the message.
32-
*
33-
* @return $this
34+
* Get the message envelope.
35+
*/
36+
public function envelope(): Envelope
37+
{
38+
return new Envelope(
39+
from: new Address(config('app.email'), 'Kanka Team'),
40+
subject: 'Confirmation: ' . $this->user->pledge . ' subscription cancellation',
41+
tags: ['cancelled']
42+
);
43+
}
44+
45+
/**
46+
* Get the message content definition.
3447
*/
35-
public function build()
48+
public function content(): Content
3649
{
37-
return $this
38-
->from(['address' => config('app.email'), 'name' => 'Kanka Team'])
39-
->subject('Confirmation: ' . $this->user->pledge . ' subscription cancellation')
40-
->tag('cancelled')
41-
->view('emails.subscriptions.cancelled.user-html');
50+
return new Content(
51+
markdown: 'emails.subscriptions.cancelled.user-md',
52+
);
4253
}
4354
}

app/Mail/Subscription/User/ExpiringCardEmail.php

+20-10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
use App\Models\User;
66
use Illuminate\Bus\Queueable;
77
use Illuminate\Mail\Mailable;
8+
use Illuminate\Mail\Mailables\Address;
9+
use Illuminate\Mail\Mailables\Content;
10+
use Illuminate\Mail\Mailables\Envelope;
811
use Illuminate\Queue\SerializesModels;
912

1013
class ExpiringCardEmail extends Mailable
@@ -30,17 +33,24 @@ public function __construct(User $user)
3033
}
3134

3235
/**
33-
* Build the message.
34-
*
35-
* @return $this
36+
* Get the message envelope.
37+
*/
38+
public function envelope(): Envelope
39+
{
40+
return new Envelope(
41+
from: new Address(config('app.email'), 'Kanka Team'),
42+
subject: __('emails/subscriptions/expiring.title'),
43+
tags: ['expiring']
44+
);
45+
}
46+
47+
/**
48+
* Get the message content definition.
3649
*/
37-
public function build()
50+
public function content(): Content
3851
{
39-
return $this
40-
->from(['address' => config('app.email'), 'name' => 'Kanka Team'])
41-
->subject(__('emails/subscriptions/expiring.title'))
42-
->view('emails.subscriptions.expiring.user-html')
43-
->tag('expiring')
44-
->text('emails.subscriptions.expiring.user-text');
52+
return new Content(
53+
markdown: 'emails.subscriptions.expiring.user-md',
54+
);
4555
}
4656
}

app/Mail/Subscription/User/FailedUserSubscriptionMail.php

+20-9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
use App\Models\User;
66
use Illuminate\Bus\Queueable;
77
use Illuminate\Mail\Mailable;
8+
use Illuminate\Mail\Mailables\Address;
9+
use Illuminate\Mail\Mailables\Content;
10+
use Illuminate\Mail\Mailables\Envelope;
811
use Illuminate\Queue\SerializesModels;
912

1013
class FailedUserSubscriptionMail extends Mailable
@@ -28,16 +31,24 @@ public function __construct(User $user)
2831
}
2932

3033
/**
31-
* Build the message.
32-
*
33-
* @return $this
34+
* Get the message envelope.
35+
*/
36+
public function envelope(): Envelope
37+
{
38+
return new Envelope(
39+
from: new Address(config('app.email'), 'Kanka Team'),
40+
subject: 'Warning: subscription issue',
41+
tags: ['failed']
42+
);
43+
}
44+
45+
/**
46+
* Get the message content definition.
3447
*/
35-
public function build()
48+
public function content(): Content
3649
{
37-
return $this
38-
->from(['address' => config('app.email'), 'name' => 'Kanka Team'])
39-
->subject('Warning: subscription issue')
40-
->tag('failed')
41-
->view('emails.subscriptions.charge-failed.user-html');
50+
return new Content(
51+
markdown: 'emails.subscriptions.charge-failed.user-md',
52+
);
4253
}
4354
}

app/Mail/Subscription/User/NewElementalSubscriptionMail.php

+28-9
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22

33
namespace App\Mail\Subscription\User;
44

5+
use App\Models\Pledge;
6+
use App\Models\Tier;
57
use App\Models\User;
68
use Illuminate\Bus\Queueable;
79
use Illuminate\Mail\Mailable;
10+
use Illuminate\Mail\Mailables\Address;
11+
use Illuminate\Mail\Mailables\Content;
12+
use Illuminate\Mail\Mailables\Envelope;
813
use Illuminate\Queue\SerializesModels;
914

1015
class NewElementalSubscriptionMail extends Mailable
@@ -17,6 +22,11 @@ class NewElementalSubscriptionMail extends Mailable
1722
*/
1823
public $user;
1924

25+
/**
26+
* @var Tier
27+
*/
28+
public $tier;
29+
2030
/**
2131
* Create a new message instance.
2232
*
@@ -25,19 +35,28 @@ class NewElementalSubscriptionMail extends Mailable
2535
public function __construct(User $user)
2636
{
2737
$this->user = $user;
38+
$this->tier = Tier::where('name', Pledge::ELEMENTAL)->first();
2839
}
2940

3041
/**
31-
* Build the message.
32-
*
33-
* @return $this
42+
* Get the message envelope.
43+
*/
44+
public function envelope(): Envelope
45+
{
46+
return new Envelope(
47+
from: new Address(config('app.email'), 'Kanka Team'),
48+
subject: 'Thank you, and welcome!',
49+
tags: ['elemental']
50+
);
51+
}
52+
53+
/**
54+
* Get the message content definition.
3455
*/
35-
public function build()
56+
public function content(): Content
3657
{
37-
return $this
38-
->from(['address' => config('app.email'), 'name' => 'Kanka Team'])
39-
->subject('Thank you, and welcome!')
40-
->tag('elemental')
41-
->view('emails.subscriptions.new.elemental');
58+
return new Content(
59+
markdown: 'emails.subscriptions.new.elemental',
60+
);
4261
}
4362
}

app/Mail/Subscription/User/NewSubscriberMail.php

+20-9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
use App\Models\User;
77
use Illuminate\Bus\Queueable;
88
use Illuminate\Mail\Mailable;
9+
use Illuminate\Mail\Mailables\Address;
10+
use Illuminate\Mail\Mailables\Content;
11+
use Illuminate\Mail\Mailables\Envelope;
912
use Illuminate\Queue\SerializesModels;
1013

1114
class NewSubscriberMail extends Mailable
@@ -29,16 +32,24 @@ public function __construct(User $user, Tier $tier)
2932
}
3033

3134
/**
32-
* Build the message.
33-
*
34-
* @return $this
35+
* Get the message envelope.
36+
*/
37+
public function envelope(): Envelope
38+
{
39+
return new Envelope(
40+
from: new Address(config('app.email'), 'Kanka Team'),
41+
subject: 'Thank you, and welcome!',
42+
tags: ['elemental']
43+
);
44+
}
45+
46+
/**
47+
* Get the message content definition.
3548
*/
36-
public function build()
49+
public function content(): Content
3750
{
38-
return $this
39-
->from(['address' => config('app.email'), 'name' => 'Kanka Team'])
40-
->subject('Thank you, and welcome!')
41-
->tag('elemental')
42-
->view('emails.subscriptions.new.' . $this->tier->code);
51+
return new Content(
52+
markdown: 'emails.subscriptions.new.' . $this->tier->code,
53+
);
4354
}
4455
}

app/Mail/WelcomeEmail.php

+21-10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
use App\Models\User;
66
use Illuminate\Bus\Queueable;
77
use Illuminate\Mail\Mailable;
8+
use Illuminate\Mail\Mailables\Address;
9+
use Illuminate\Mail\Mailables\Content;
10+
use Illuminate\Mail\Mailables\Envelope;
811
use Illuminate\Queue\SerializesModels;
912

1013
class WelcomeEmail extends Mailable
@@ -28,17 +31,25 @@ public function __construct(User $user)
2831
}
2932

3033
/**
31-
* Build the message.
32-
*
33-
* @return $this
34+
* Get the message envelope.
35+
*/
36+
public function envelope(): Envelope
37+
{
38+
return new Envelope(
39+
subject: __('emails/welcome.title'),
40+
tags: ['welcome'],
41+
from: new Address(config('app.email'), 'Kanka.io'),
42+
);
43+
}
44+
45+
/**
46+
* Get the message content definition.
3447
*/
35-
public function build()
48+
public function content(): Content
3649
{
37-
return $this
38-
->from(['address' => config('app.email'), 'name' => 'Kanka.io'])
39-
->subject(__('emails/welcome.title'))
40-
->tag('welcome')
41-
->view('emails.welcome.2024.html')
42-
->text('emails.welcome.2024.text');
50+
return new Content(
51+
markdown: 'emails.welcome.2024.text',
52+
with: ['user' => $this->user],
53+
);
4354
}
4455
}

0 commit comments

Comments
 (0)