2026-03-11 23:33:10 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Mail;
|
|
|
|
|
|
2026-03-12 18:25:32 +00:00
|
|
|
use App\Models\Declaration;
|
2026-03-11 23:33:10 +00:00
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
|
use Illuminate\Mail\Mailable;
|
|
|
|
|
use Illuminate\Mail\Mailables\Content;
|
|
|
|
|
use Illuminate\Mail\Mailables\Envelope;
|
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
|
|
2026-03-12 18:25:32 +00:00
|
|
|
class DeclarationTextMessageMail extends Mailable
|
2026-03-11 23:33:10 +00:00
|
|
|
{
|
|
|
|
|
use Queueable, SerializesModels;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new message instance.
|
|
|
|
|
*
|
2026-03-12 18:25:32 +00:00
|
|
|
* @param string|null $token When set, recipient is client (use token-based URL). When null, recipient is comptable (use declarations.show).
|
2026-03-11 23:33:10 +00:00
|
|
|
*/
|
|
|
|
|
public function __construct(
|
2026-03-12 18:25:32 +00:00
|
|
|
public Declaration $declaration,
|
2026-03-11 23:33:10 +00:00
|
|
|
public string $body,
|
|
|
|
|
public ?string $token = null
|
|
|
|
|
) {}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the message envelope.
|
|
|
|
|
*/
|
|
|
|
|
public function envelope(): Envelope
|
|
|
|
|
{
|
|
|
|
|
return new Envelope(
|
2026-03-12 18:25:32 +00:00
|
|
|
subject: 'Nouveau message - '.$this->declaration->title,
|
2026-03-11 23:33:10 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the message content definition.
|
|
|
|
|
*/
|
|
|
|
|
public function content(): Content
|
|
|
|
|
{
|
|
|
|
|
$messagesUrl = $this->token
|
|
|
|
|
? route('client.upload', ['token' => $this->token])
|
2026-03-12 18:25:32 +00:00
|
|
|
: route('declarations.show', ['declaration' => $this->declaration]).'?tab=messages';
|
2026-03-11 23:33:10 +00:00
|
|
|
|
|
|
|
|
return new Content(
|
2026-03-12 18:25:32 +00:00
|
|
|
markdown: 'emails.declaration-text-message',
|
2026-03-11 23:33:10 +00:00
|
|
|
with: [
|
2026-03-12 18:25:32 +00:00
|
|
|
'declarationTitle' => $this->declaration->title,
|
2026-03-11 23:33:10 +00:00
|
|
|
'body' => $this->body,
|
|
|
|
|
'messagesUrl' => $messagesUrl,
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|