remove unecessary delete notifications on validate user

This commit is contained in:
2026-03-12 11:01:44 +01:00
parent d2dd44af4d
commit c16a9d1785
2 changed files with 0 additions and 52 deletions
-44
View File
@@ -1,44 +0,0 @@
<?php
namespace App\Events;
use App\Models\User;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class UserValidated implements ShouldBroadcastNow
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $user;
/**
* Create a new event instance.
*/
public function __construct(User $user)
{
$this->user = $user;
}
/**
* Get the channels the event should broadcast on.
*
* @return array<int, \Illuminate\Broadcasting\Channel>
*/
public function broadcastOn(): array
{
return [
new privateChannel('users.admin'),
];
}
public function broadcastAs()
{
return 'users.validation';
}
}
-8
View File
@@ -183,13 +183,6 @@ class UserController extends Controller
try {
$user = User::find($id);
$notifications = Notification::where('user_id', $user->id)->get();
foreach ($notifications as $notification) {
$notification->users()->detach();
$notification->delete();
}
$user->validate = 1;
$user->role = 3;
$user->verified_at = now();
@@ -201,7 +194,6 @@ class UserController extends Controller
'lastname' => $user->lastname,
];
Mail::to($user->email)->send(new ValidateMail($data));
broadcast(new UserValidated($user));
return response()->json(['message' => 'User validated successfully']);