改进
This commit is contained in:
parent
45129f95cb
commit
81d5d57fc4
@ -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;
|
||||
|
@ -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));
|
||||
});
|
||||
|
||||
|
@ -9,12 +9,12 @@
|
||||
{{-- 修改主机 --}}
|
||||
<form method="post" action="{{ route('admin.hosts.update', $host) }}">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
@method('PATCH')
|
||||
|
||||
{{-- <div class="form-group">--}}
|
||||
{{-- <label for="name" class="col-sm-2 col-form-label">名称</label>--}}
|
||||
{{-- <input type="text" class="form-control" id="name" name="name" value="{{ $host->name }}">--}}
|
||||
{{-- </div>--}}
|
||||
<div class="form-group">
|
||||
<label for="name" class="col-sm-2 col-form-label">名称</label>
|
||||
<input type="text" class="form-control" id="name" name="name" value="{{ $host->name }}">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="managed_price" class="col-sm-2 col-form-label">新的价格 (元)</label>
|
||||
@ -23,6 +23,15 @@
|
||||
留空以使用默认价格
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="status" class="col-sm-2 col-form-label">状态</label>
|
||||
<select class="form-control" id="status" name="status">
|
||||
<option value="running" {{ $host->status == 'running' ? 'selected' : '' }}>运行中</option>
|
||||
<option value="stopped" {{ $host->status == 'stopped' ? 'selected' : '' }}>已停止</option>
|
||||
<option value="suspended" {{ $host->status == 'suspended' ? 'selected' : '' }}>已暂停</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary mt-3">修改</button>
|
||||
|
||||
</form>
|
||||
@ -34,7 +43,4 @@
|
||||
<button type="submit" class="btn btn-danger mt-3">删除</button>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
|
||||
@endsection
|
||||
|
Loading…
Reference in New Issue
Block a user