Skip to content

Commit 7e1db09

Browse files
authoredMar 28, 2025
Merge pull request #1026 from owlchester/migrate-user-emails-to-md
Migrate User Emails to MD
2 parents 09e6ea2 + e969adf commit 7e1db09

40 files changed

+560
-577
lines changed
 

‎app/Console/Commands/Tests/TestEmail.php

+17
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22

33
namespace App\Console\Commands\Tests;
44

5+
use App\Jobs\Emails\NewFeatureEmailJob;
6+
use App\Jobs\Emails\Purge\FirstWarningJob;
7+
use App\Jobs\Emails\Purge\SecondWarningJob;
58
use App\Jobs\Emails\SubscriptionCancelEmailJob;
9+
use App\Jobs\Emails\SubscriptionDowngradedEmailJob;
610
use App\Jobs\Emails\SubscriptionFailedEmailJob;
711
use App\Jobs\Emails\Subscriptions\ExpiringCardAlert;
812
use App\Jobs\Emails\Subscriptions\UpcomingYearlyAlert;
913
use App\Jobs\Emails\Subscriptions\WelcomeSubscriptionEmailJob;
1014
use App\Jobs\Emails\WelcomeEmailJob;
15+
use App\Jobs\Users\NewPassword;
16+
use App\Models\Feature;
1117
use App\Models\Tier;
1218
use Illuminate\Console\Command;
1319

@@ -42,6 +48,8 @@ public function handle()
4248
WelcomeEmailJob::dispatch($user, 'en');
4349
} elseif ($template === 'cancelled') {
4450
SubscriptionCancelEmailJob::dispatch($user, null, 'custom text');
51+
} elseif ($template === 'downgrade') {
52+
SubscriptionDowngradedEmailJob::dispatch($user);
4553
} elseif ($template === 'elemental') {
4654
WelcomeSubscriptionEmailJob::dispatch($user, Tier::where('name', 'elemental')->first());
4755
} elseif ($template === 'wyvern') {
@@ -54,6 +62,15 @@ public function handle()
5462
SubscriptionFailedEmailJob::dispatch($user);
5563
} elseif ($template === 'upcoming') {
5664
UpcomingYearlyAlert::dispatch($user);
65+
} elseif ($template === 'password') {
66+
NewPassword::dispatch($user);
67+
} elseif ($template === 'first') {
68+
FirstWarningJob::dispatch($user->id);
69+
} elseif ($template === 'second') {
70+
SecondWarningJob::dispatch($user->id);
71+
} elseif ($template === 'feature') {
72+
$feature = Feature::latest()->first();
73+
NewFeatureEmailJob::dispatch($feature);
5774
} else {
5875
$this->warn('Unknown template ' . $template);
5976
}

‎app/Mail/Features/NewFeatureMail.php

+2-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use App\Models\Feature;
66
use Illuminate\Bus\Queueable;
77
use Illuminate\Mail\Mailable;
8-
use Illuminate\Mail\Mailables\Address;
98
use Illuminate\Mail\Mailables\Content;
109
use Illuminate\Mail\Mailables\Envelope;
1110
use Illuminate\Queue\SerializesModels;
@@ -15,10 +14,7 @@ class NewFeatureMail extends Mailable
1514
use Queueable;
1615
use SerializesModels;
1716

18-
/**
19-
* @var Feature
20-
*/
21-
public $feature;
17+
public Feature $feature;
2218

2319
/**
2420
* Create a new message instance.
@@ -38,7 +34,6 @@ public function envelope(): Envelope
3834
return new Envelope(
3935
subject: 'New feature request',
4036
tags: ['admin-new-feature'],
41-
from: new Address(config('app.email'), 'Kanka Admin'),
4237
);
4338
}
4439

@@ -48,7 +43,7 @@ public function envelope(): Envelope
4843
public function content(): Content
4944
{
5045
return new Content(
51-
markdown: 'emails.features.md',
46+
markdown: 'emails.features.new',
5247
with: ['feature' => $this->feature],
5348
);
5449
}

‎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

+18-10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use App\Models\User;
66
use Illuminate\Bus\Queueable;
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 ExpiringCardEmail extends Mailable
@@ -30,17 +32,23 @@ public function __construct(User $user)
3032
}
3133

3234
/**
33-
* Build the message.
34-
*
35-
* @return $this
35+
* Get the message envelope.
36+
*/
37+
public function envelope(): Envelope
38+
{
39+
return new Envelope(
40+
subject: __('emails/subscriptions/expiring.title'),
41+
tags: ['expiring']
42+
);
43+
}
44+
45+
/**
46+
* Get the message content definition.
3647
*/
37-
public function build()
48+
public function content(): Content
3849
{
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');
50+
return new Content(
51+
markdown: 'emails.subscriptions.expiring.user-md',
52+
);
4553
}
4654
}

‎app/Mail/Subscription/User/FailedUserSubscriptionMail.php

+18-9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use App\Models\User;
66
use Illuminate\Bus\Queueable;
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 FailedUserSubscriptionMail extends Mailable
@@ -28,16 +30,23 @@ public function __construct(User $user)
2830
}
2931

3032
/**
31-
* Build the message.
32-
*
33-
* @return $this
33+
* Get the message envelope.
34+
*/
35+
public function envelope(): Envelope
36+
{
37+
return new Envelope(
38+
subject: 'Issue with your Kanka subscription',
39+
tags: ['failed']
40+
);
41+
}
42+
43+
/**
44+
* Get the message content definition.
3445
*/
35-
public function build()
46+
public function content(): Content
3647
{
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');
48+
return new Content(
49+
markdown: 'emails.subscriptions.charge-failed.user-md',
50+
);
4251
}
4352
}

‎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/Subscription/User/UpcomingYearlyEmail.php

+16-10
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
use Carbon\Carbon;
77
use Illuminate\Bus\Queueable;
88
use Illuminate\Mail\Mailable;
9+
use Illuminate\Mail\Mailables\Content;
10+
use Illuminate\Mail\Mailables\Envelope;
911
use Illuminate\Queue\SerializesModels;
1012

1113
class UpcomingYearlyEmail extends Mailable
@@ -32,17 +34,21 @@ public function __construct(User $user)
3234
}
3335

3436
/**
35-
* Build the message.
36-
*
37-
* @return $this
37+
* Get the message envelope.
3838
*/
39-
public function build()
39+
public function envelope(): Envelope
40+
{
41+
return new Envelope(
42+
subject: __('emails/subscriptions/upcoming.title'),
43+
tags: ['user', 'upcoming-yearly'],
44+
);
45+
}
46+
47+
public function content(): Content
4048
{
41-
return $this
42-
->from(['address' => config('app.email'), 'name' => 'Kanka Team'])
43-
->subject(__('emails/subscriptions/upcoming.title'))
44-
->view('emails.subscriptions.upcoming.user-html')
45-
->tag('upcoming-yearly')
46-
->text('emails.subscriptions.upcoming.user-text');
49+
return new Content(
50+
markdown: 'emails.subscriptions.upcoming.user',
51+
with: ['user' => $this->user, 'date' => $this->date],
52+
);
4753
}
4854
}

0 commit comments

Comments
 (0)