From 81d5d57fc4adcc134a5eb4bddfd0980e066eaa3d Mon Sep 17 00:00:00 2001 From: "iVampireSP.com" Date: Fri, 13 Jan 2023 18:10:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Jobs/Module/HostJob.php | 2 +- app/Models/Host.php | 16 +++------------- resources/views/admin/hosts/edit.blade.php | 22 ++++++++++++++-------- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/app/Jobs/Module/HostJob.php b/app/Jobs/Module/HostJob.php index 024fd24..87f26d2 100644 --- a/app/Jobs/Module/HostJob.php +++ b/app/Jobs/Module/HostJob.php @@ -22,7 +22,7 @@ class HostJob implements ShouldQueue * * @return void */ - public function __construct($host, $type = 'post') + public function __construct(HostModel $host, $type = 'post') { // $this->host = $host; diff --git a/app/Models/Host.php b/app/Models/Host.php index 6fc6d1d..5c9a8ad 100644 --- a/app/Models/Host.php +++ b/app/Models/Host.php @@ -53,7 +53,7 @@ protected static function boot() }); static::created(function (self $model) { - // broadcast(new Users($model->user, 'success', $model)); + $model->user->notify(new WebNotification($model, 'hosts.created')); }); @@ -68,24 +68,14 @@ protected static function boot() } } - // if ($model->isDirty('price')) { - // $model->price = round($model->price, 2); - // } - - // if ($model->isDirty('managed_price') && $model->managed_price !== null) { - // $model->managed_price = round($model->managed_price, 2); - // } + // 调度任务 + dispatch(new HostJob($model, 'patch')); broadcast(new Users($model->user_id, 'hosts.updating', $model)); }); // when Updated static::updated(function ($model) { - dispatch(new HostJob($model, 'patch')); - - Cache::forget('user_hosts_' . $model->user_id); - Cache::forget('user_tasks_' . $model->user_id); - broadcast(new Users($model->user_id, 'hosts.updated', $model)); }); diff --git a/resources/views/admin/hosts/edit.blade.php b/resources/views/admin/hosts/edit.blade.php index d8ca867..9dd4d07 100644 --- a/resources/views/admin/hosts/edit.blade.php +++ b/resources/views/admin/hosts/edit.blade.php @@ -9,12 +9,12 @@ {{-- 修改主机 --}}
@csrf - @method('PUT') + @method('PATCH') - {{--
--}} - {{-- --}} - {{-- --}} - {{--
--}} +
+ + +
@@ -23,6 +23,15 @@ 留空以使用默认价格
+
+ + +
+
@@ -34,7 +43,4 @@ - - - @endsection