41 lines
1.3 KiB
PHP
41 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\Models\IntegrationRequest;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class IntegrationCompletedWithAttachment extends Notification implements ShouldQueue
|
|
{
|
|
use Queueable;
|
|
|
|
public function __construct(
|
|
public IntegrationRequest $integrationRequest,
|
|
public string $base64PdfContent
|
|
) {}
|
|
|
|
public function via($notifiable): array
|
|
{
|
|
return ['mail'];
|
|
}
|
|
|
|
public function toMail($notifiable): MailMessage
|
|
{
|
|
$agentName = $this->integrationRequest->agent->first_name . ' ' . $this->integrationRequest->agent->last_name;
|
|
$filename = "Fiche_Agent_{$this->integrationRequest->agent->last_name}_{$this->integrationRequest->agent->first_name}.pdf";
|
|
|
|
$pdfContent = base64_decode($this->base64PdfContent);
|
|
|
|
return (new MailMessage)
|
|
->subject("Intégration terminée - {$agentName}")
|
|
->line("L'intégration de l'agent {$agentName} est désormais terminée.")
|
|
->line("Veuillez trouver la fiche agent récapitulative en pièce jointe.")
|
|
->attachData($pdfContent, $filename, [
|
|
'mime' => 'application/pdf',
|
|
]);
|
|
}
|
|
}
|