60 lines
1.6 KiB
PHP
60 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
class ExportTicketsStateNotification extends Notification implements ShouldQueue
|
|
{
|
|
use Queueable;
|
|
|
|
/**
|
|
* The CSV content to be sent.
|
|
*
|
|
* @var string
|
|
*/
|
|
private string $csvContent;
|
|
|
|
/**
|
|
* Create a new notification instance.
|
|
*
|
|
* @param string $csvContent The content of the CSV file to be sent.
|
|
*/
|
|
public function __construct(string $csvContent)
|
|
{
|
|
$this->csvContent = $csvContent;
|
|
}
|
|
|
|
/**
|
|
* Get the notification's delivery channels.
|
|
*
|
|
* @return array<int, string>
|
|
*/
|
|
public function via(): array
|
|
{
|
|
return ['mail'];
|
|
}
|
|
|
|
/**
|
|
* Get the mail representation of the notification.
|
|
*
|
|
* @return \Illuminate\Notifications\Messages\MailMessage
|
|
*/
|
|
public function toMail(): \Illuminate\Notifications\Messages\MailMessage
|
|
{
|
|
return (new MailMessage())
|
|
->subject(trans("Export de l'état des lieux des tickets"))
|
|
->line(trans("Vous trouverez ci-joint le fichier CSV contenant l'état des tickets."))
|
|
->attachData(
|
|
$this->csvContent,
|
|
sprintf('tickets_state_%s.csv', Carbon::now()->format('Y-m-d_H-i-s')),
|
|
[
|
|
'mime' => 'text/csv',
|
|
]
|
|
);
|
|
}
|
|
}
|