add event user_updated

This commit is contained in:
xiaomlove
2024-12-24 22:22:02 +08:00
parent d8ce2bd638
commit b9f5641985
3 changed files with 45 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ use App\Events\UserCreated;
use App\Events\UserDestroyed; use App\Events\UserDestroyed;
use App\Events\UserDisabled; use App\Events\UserDisabled;
use App\Events\UserEnabled; use App\Events\UserEnabled;
use App\Events\UserUpdated;
use App\Models\News; use App\Models\News;
use App\Models\Torrent; use App\Models\Torrent;
use App\Models\User; use App\Models\User;
@@ -43,6 +44,7 @@ class FireEvent extends Command
"user_destroyed" => ['event' => UserDestroyed::class, 'model' => User::class], "user_destroyed" => ['event' => UserDestroyed::class, 'model' => User::class],
"user_disabled" => ['event' => UserDisabled::class, 'model' => User::class], "user_disabled" => ['event' => UserDisabled::class, 'model' => User::class],
"user_enabled" => ['event' => UserEnabled::class, 'model' => User::class], "user_enabled" => ['event' => UserEnabled::class, 'model' => User::class],
"user_updated" => ['event' => UserUpdated::class, 'model' => User::class],
"news_created" => ['event' => NewsCreated::class, 'model' => News::class], "news_created" => ['event' => NewsCreated::class, 'model' => News::class],
]; ];

View File

@@ -0,0 +1,39 @@
<?php
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class UserUpdated
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public ?Model $model = null;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct(Model $model)
{
$this->model = $model;
}
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
return new PrivateChannel('channel-name');
}
}

View File

@@ -1070,6 +1070,10 @@ function clear_user_cache($uid, $passkey = '')
if ($passkey) { if ($passkey) {
\Nexus\Database\NexusDB::cache_del('user_passkey_'.$passkey.'_content');//announce.php \Nexus\Database\NexusDB::cache_del('user_passkey_'.$passkey.'_content');//announce.php
} }
$userInfo = \App\Models\User::query()->find($uid, \App\Models\User::$commonFields);
if ($userInfo) {
fire_event("user_updated", $userInfo);
}
} }
function clear_setting_cache() function clear_setting_cache()