create a mail when a user is unassigned to a task by an administrator
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Events\TaskParticipationCancelled;
|
||||
use App\Events\VolunteerAssignedToTask;
|
||||
use App\Events\VolunteerUnassignedFromTask;
|
||||
use App\Mail\VolunteerAssignToTaskMail;
|
||||
use App\Mail\VolunteerUnassignToTaskMail;
|
||||
use App\Models\Events;
|
||||
use App\Models\Task;
|
||||
use App\Models\User;
|
||||
@@ -244,6 +245,15 @@ class TasksController extends Controller
|
||||
$task,
|
||||
$event
|
||||
));
|
||||
|
||||
$data = [
|
||||
'name' => $user->name,
|
||||
'lastname' => $user->lastname,
|
||||
'taskName' => $task->name,
|
||||
'start' => $task->start,
|
||||
'end' => $task->end,
|
||||
];
|
||||
Mail::to($user->email)->send(new VolunteerUnassignToTaskMail($data));
|
||||
}
|
||||
|
||||
return response()->json(['message' => "User unassigned successfully"], 200);
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
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\Queue\SerializesModels;
|
||||
|
||||
class VolunteerUnassignToTaskMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Désassignation - Comité des fêtes de Beaupont',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'mails.volunteerUnassignToTask',
|
||||
with: [
|
||||
'name' => $this->data['name'],
|
||||
'lastname' => $this->data['lastname'],
|
||||
'taskName' => $this->data['taskName'],
|
||||
'start' => $this->data['start'],
|
||||
'end' => $this->data['end'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Désassignation</title>
|
||||
</head>
|
||||
<body style="padding: 20px; font-family: Arial, sans-serif;">
|
||||
<div>
|
||||
<p>Bonjour {{ $name }} {{ $lastname }},</p>
|
||||
|
||||
<p>
|
||||
Vous avez été désassigné de la tâche {{ $taskName }} par un administrateur.
|
||||
Cette tâche avait lieu de {{ $start }} à {{ $end }}. Vous n'y participez donc plus.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Si vous pensez qu’il s’agit d’une erreur ou si vous souhaitez plus d’informations,
|
||||
merci de contacter l’équipe du Comité des fêtes de Beaupont.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
À très bientôt,<br>
|
||||
L’équipe du Comité des fêtes de Beaupont
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<p style="font-size: 14px; color: #999; text-align: center; padding-top: 20px;">
|
||||
Cet email a été envoyé automatiquement, merci de ne pas y répondre.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user