create a mail when an event is deleted to the participants
This commit is contained in:
@@ -3,12 +3,15 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Events\EventParticipationCancelled;
|
use App\Events\EventParticipationCancelled;
|
||||||
|
use App\Mail\EventParticipationCancelledMail;
|
||||||
|
use App\Mail\ValidateMail;
|
||||||
use App\Models\Events;
|
use App\Models\Events;
|
||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Support\Facades\Gate;
|
use Illuminate\Support\Facades\Gate;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
|
||||||
|
|
||||||
class EventsController extends Controller
|
class EventsController extends Controller
|
||||||
@@ -100,6 +103,14 @@ class EventsController extends Controller
|
|||||||
$user->id,
|
$user->id,
|
||||||
$event
|
$event
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'name' => $user->name,
|
||||||
|
'lastname' => $user->lastname,
|
||||||
|
'eventName' => $event->name,
|
||||||
|
];
|
||||||
|
Mail::to($user->email)->send(new EventParticipationCancelledMail($data));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$event->delete();
|
$event->delete();
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
<?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 EventParticipationCancelledMail 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: 'Evénement supprimé - Comité des fêtes de Beaupont',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the message content definition.
|
||||||
|
*/
|
||||||
|
public function content(): Content
|
||||||
|
{
|
||||||
|
return new Content(
|
||||||
|
view: 'mails.eventParticipationCancelled',
|
||||||
|
with: [
|
||||||
|
'name' => $this->data['name'],
|
||||||
|
'lastname' => $this->data['lastname'],
|
||||||
|
'eventName' => $this->data['eventName'],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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>Événement supprimé</title>
|
||||||
|
</head>
|
||||||
|
<body style="padding: 20px; font-family: Arial, sans-serif;">
|
||||||
|
<div>
|
||||||
|
<p>Bonjour {{ $name }} {{ $lastname }},</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
L’événement {{ $eventName }} a été supprimé par un administrateur.
|
||||||
|
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