diff --git a/app/Models/Host.php b/app/Models/Host.php index 4d21195..f8d413e 100644 --- a/app/Models/Host.php +++ b/app/Models/Host.php @@ -198,6 +198,7 @@ protected static function boot() static::created(function ($model) { broadcast(new UserEvent($model->user_id, 'hosts.created', $model)); + Cache::forget('user_tasks_' . $model->user_id); }); static::updating(function ($model) { @@ -206,6 +207,8 @@ protected static function boot() } else if ($model->status == 'running') { $model->suspended_at = null; } + Cache::forget('user_tasks_' . $model->user_id); + broadcast(new UserEvent($model->user_id, 'hosts.updating', $model)); }); @@ -215,6 +218,8 @@ protected static function boot() dispatch(new \App\Jobs\Remote\Host($model, 'patch')); Cache::forget('user_hosts_' . $model->user_id); + Cache::forget('user_tasks_' . $model->user_id); + broadcast(new UserEvent($model->user_id, 'hosts.updated', $model)); }); @@ -224,9 +229,13 @@ protected static function boot() // broadcast(new UserEvent($model->user_id, 'hosts.deleting', $model)); // }); + static::deleting(function ($model) { + Cache::forget('user_tasks_' . $model->user_id); + }); + static::deleted(function ($model) { broadcast(new UserEvent($model->user_id, 'hosts.deleted', $model)); - + Cache::forget('user_tasks_' . $model->user_id); Cache::forget('user_hosts_' . $model->user_id); }); }