create notification on delete event
This commit is contained in:
1 parent
d51d6a9c3f
commit
2dcc861317
1 file changed
+6
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
|||||||
|
|
||||||
use App\Events\EventParticipationCancelled;
|
use App\Events\EventParticipationCancelled;
|
||||||
use App\Models\Events;
|
use App\Models\Events;
|
||||||
|
use App\Models\Notification;
|
||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
@@ -95,6 +96,11 @@ class EventsController extends Controller
|
|||||||
return $task->users;
|
return $task->users;
|
||||||
})->unique('id');
|
})->unique('id');
|
||||||
|
|
||||||
|
$notification = Notification::create([
|
||||||
|
'content' => "L'événement '{$event->name}' a été supprimé. Vous n'y participez donc plus."
|
||||||
|
]);
|
||||||
|
$notification->users()->attach($participants->pluck('id'));
|
||||||
|
|
||||||
foreach ($participants as $user) {
|
foreach ($participants as $user) {
|
||||||
broadcast(new EventParticipationCancelled(
|
broadcast(new EventParticipationCancelled(
|
||||||
$user->id,
|
$user->id,
|
||||||
|
|||||||
Reference in new issue
Block a user