remove unecessary delete notifications on validate user
This commit is contained in:
1 parent
d2dd44af4d
commit
c16a9d1785
2 files changed
-52
No files matched your search
@@ -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';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -183,13 +183,6 @@ class UserController extends Controller
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$user = User::find($id);
|
$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->validate = 1;
|
||||||
$user->role = 3;
|
$user->role = 3;
|
||||||
$user->verified_at = now();
|
$user->verified_at = now();
|
||||||
@@ -201,7 +194,6 @@ class UserController extends Controller
|
|||||||
'lastname' => $user->lastname,
|
'lastname' => $user->lastname,
|
||||||
];
|
];
|
||||||
Mail::to($user->email)->send(new ValidateMail($data));
|
Mail::to($user->email)->send(new ValidateMail($data));
|
||||||
broadcast(new UserValidated($user));
|
|
||||||
|
|
||||||
return response()->json(['message' => 'User validated successfully']);
|
return response()->json(['message' => 'User validated successfully']);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user