From 9cbd9904a23c87774b99fbfe019caa1d4c6569e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anna-Sara=20S=C3=A9lea?= Date: Sat, 7 Feb 2026 18:48:04 +0100 Subject: [PATCH] Added code to send sms when mail is sent --- .../Participants/Tables/ParticipantsTable.php | 7 +- app/Mail/SmsMail.php | 86 +++++++++++++++++++ config/app.php | 1 + resources/views/mail/sms.blade.php | 1 + 4 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 app/Mail/SmsMail.php create mode 100644 resources/views/mail/sms.blade.php diff --git a/app/Filament/Resources/Participants/Tables/ParticipantsTable.php b/app/Filament/Resources/Participants/Tables/ParticipantsTable.php index 8284f66..1929a47 100644 --- a/app/Filament/Resources/Participants/Tables/ParticipantsTable.php +++ b/app/Filament/Resources/Participants/Tables/ParticipantsTable.php @@ -15,6 +15,7 @@ use Filament\Actions\Action; use Filament\Forms\Components\Select; use Illuminate\Support\Facades\Mail; use App\Mail\LanMail; +use App\Mail\SmsMail; use Filament\Support\Icons\Heroicon; use App\Filament\Exports\ParticipantExporter; use Filament\Actions\ExportAction; @@ -146,6 +147,9 @@ class ParticipantsTable Mail::to($record->guardian_email) ->send(new LanMail($mailContent, $record)); Participant::where('id', $record->id)->update(['emailed' => true]); + Mail::to(config('app.smsUrl')) + ->send(new SmsMail($record)); + }) ->hidden(fn($record) => $record->emailed), Action::make('sendRemindEmail') @@ -162,8 +166,7 @@ class ParticipantsTable ->queue(new LanMail($mailContent, $record)); Participant::where('id', $record->id)->update(['emailed' => true]); }) - ->hidden(fn($record) => !$record->emailed) - + ->hidden(fn($record) => !$record->emailed), ]) ->toolbarActions([ BulkActionGroup::make([ diff --git a/app/Mail/SmsMail.php b/app/Mail/SmsMail.php new file mode 100644 index 0000000..08b56da --- /dev/null +++ b/app/Mail/SmsMail.php @@ -0,0 +1,86 @@ +name = $participant->first_name; + $this->phone = formatToSwedenPrefix($participant->guardian_phone); + } + + /** + * Get the message envelope. + */ + public function envelope(): Envelope + { + return new Envelope( + subject: $this->phone, + ); + } + + /** + * Get the message content definition. + */ + public function content(): Content + { + return new Content( + view: 'mail.sms', + ); + } + + /** + * Get the attachments for the message. + * + * @return array + */ + public function attachments(): array + { + return []; + } +} \ No newline at end of file diff --git a/config/app.php b/config/app.php index 26b1117..3ae91a5 100644 --- a/config/app.php +++ b/config/app.php @@ -126,5 +126,6 @@ return [ ], 'lanplace_amount' => env('LAN_PLACE_AMOUNT'), + 'smsUrl' => env('SMS_URL'), ]; diff --git a/resources/views/mail/sms.blade.php b/resources/views/mail/sms.blade.php new file mode 100644 index 0000000..b8d9471 --- /dev/null +++ b/resources/views/mail/sms.blade.php @@ -0,0 +1 @@ +

Hej! Du har fått mail från vBytes angående LAN 2026.

\ No newline at end of file