Snapshot of main at 9f39a6e1e (2026-11-02)
This commit is contained in:
commit
6ccf1792d7
2580 files changed
+1040202
No files matched your search
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\Poll;
|
||||
use App\Models\User;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
/**
|
||||
* The voter's poll receipt code. Deliberately not ShouldQueue: sent right away so
|
||||
* the code is never stored next to the address (jobs / failed_jobs tables).
|
||||
*/
|
||||
class PollReceiptMail extends Mailable
|
||||
{
|
||||
public string $mailLocale;
|
||||
public string $pollTitle;
|
||||
public ?string $verifyUrl;
|
||||
|
||||
public function __construct(public Poll $poll, public User $user, public string $receiptCode)
|
||||
{
|
||||
$this->mailLocale = $user->lang_preference ?: config('app.fallback_locale');
|
||||
|
||||
$translations = $poll->post?->translations ?? collect();
|
||||
$this->pollTitle = ($translations->firstWhere('locale', $this->mailLocale) ?? $translations->first())?->title ?? '';
|
||||
|
||||
// The verification page is added in a later step
|
||||
$this->verifyUrl = Route::has('polls.verify') ? route('polls.verify', $poll) : null;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
app()->setLocale($this->mailLocale);
|
||||
|
||||
return $this
|
||||
->from(timebank_config('mail.support.email'), timebank_config('mail.support.name'))
|
||||
->subject(__('Your poll receipt'))
|
||||
->view('emails.polls.receipt');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user