use VolunteerRoleUpdated notification
This commit is contained in:
@@ -2,11 +2,10 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Events\VolunteerRoleUpdated;
|
||||
use App\Notifications\VolunteerRoleUpdated;
|
||||
use App\Mail\CreateUserByAdminMail;
|
||||
use App\Mail\DeactivateAccountMail;
|
||||
use App\Mail\DeleteAccountMail;
|
||||
use App\Mail\UpdateRoleMail;
|
||||
use App\Mail\ValidateMail;
|
||||
use App\Models\Notification;
|
||||
use App\Models\User;
|
||||
@@ -243,27 +242,7 @@ class UserController extends Controller
|
||||
|
||||
$role = GetRole::getRole($request['role']);
|
||||
|
||||
if ($user->web_notifications) {
|
||||
$notification = Notification::create([
|
||||
'content' => "Votre rôle à changé pour : {$role}",
|
||||
]);
|
||||
$notification->users()->attach($user->id);
|
||||
|
||||
broadcast(new VolunteerRoleUpdated(
|
||||
$user->id,
|
||||
$role,
|
||||
$notification->id,
|
||||
));
|
||||
}
|
||||
|
||||
if ($user->email_notifications) {
|
||||
$data = [
|
||||
'name' => $user->name,
|
||||
'lastname' => $user->lastname,
|
||||
'role' => $role,
|
||||
];
|
||||
Mail::to($user->email)->send(new UpdateRoleMail($data));
|
||||
}
|
||||
$user->notify(new VolunteerRoleUpdated($role));
|
||||
|
||||
return response()->json(['message' => 'User role added successfully']);
|
||||
} catch(\Exception $e) {
|
||||
|
||||
Reference in New Issue
Block a user