48 lines
1.4 KiB
PHP
48 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Mail;
|
|
|
|
use App\Models\Customer;
|
|
use App\Models\MaintenanceWindow;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Mail\Mailables\Content;
|
|
use Illuminate\Mail\Mailables\Envelope;
|
|
use Illuminate\Mail\Mailables\Headers;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class MaintenanceAnnouncementMail extends Mailable implements ShouldQueue
|
|
{
|
|
use Queueable, SerializesModels;
|
|
|
|
/** The ledger row this mail confirms once actually delivered. */
|
|
public ?int $notificationId = null;
|
|
|
|
public function __construct(
|
|
public MaintenanceWindow $window,
|
|
public Customer $customer,
|
|
) {}
|
|
|
|
public function headers(): Headers
|
|
{
|
|
return new Headers(text: $this->notificationId ? ['X-CP-Notification' => (string) $this->notificationId] : []);
|
|
}
|
|
|
|
public function envelope(): Envelope
|
|
{
|
|
return new Envelope(subject: __('maintenance.mail_subject', ['title' => $this->window->title]));
|
|
}
|
|
|
|
public function content(): Content
|
|
{
|
|
return new Content(markdown: 'mail.maintenance-announcement', with: [
|
|
'title' => $this->window->title,
|
|
'description' => $this->window->public_description,
|
|
'startsAt' => $this->window->starts_at,
|
|
'endsAt' => $this->window->ends_at,
|
|
'name' => $this->customer->name,
|
|
]);
|
|
}
|
|
}
|