增加 模块状态
This commit is contained in:
parent
d2084a4726
commit
83613ac5d6
@ -61,21 +61,14 @@ public function store(Request $request): RedirectResponse
|
|||||||
$module->name = $request->name;
|
$module->name = $request->name;
|
||||||
$module->api_token = $api_token;
|
$module->api_token = $api_token;
|
||||||
$module->url = $request->url;
|
$module->url = $request->url;
|
||||||
|
$module->status = $request->status;
|
||||||
|
|
||||||
$module->save();
|
$module->save();
|
||||||
|
|
||||||
return redirect()->route('admin.modules.index')->with('success', '模块创建成功, 请重置以获得 API Token。');
|
return redirect()->route('admin.modules.index')->with('success', '模块创建成功, 请重置以获得 API Token。');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function rules(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'id' => 'required|string|max:255',
|
|
||||||
'name' => 'required|string|max:255',
|
|
||||||
'url' => 'required|url',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display the specified resource.
|
* Display the specified resource.
|
||||||
*
|
*
|
||||||
@ -128,6 +121,7 @@ public function update(Request $request, Module $module): RedirectResponse
|
|||||||
$module->id = $request->id;
|
$module->id = $request->id;
|
||||||
$module->name = $request->name;
|
$module->name = $request->name;
|
||||||
$module->url = $request->url;
|
$module->url = $request->url;
|
||||||
|
$module->status = $request->status;
|
||||||
|
|
||||||
$module->save();
|
$module->save();
|
||||||
|
|
||||||
@ -156,4 +150,15 @@ public function destroy(Module $module): RedirectResponse
|
|||||||
|
|
||||||
return redirect()->route('admin.modules.index')->with('success', '模块已删除。');
|
return redirect()->route('admin.modules.index')->with('success', '模块已删除。');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => 'required|string|max:255',
|
||||||
|
'name' => 'required|string|max:255',
|
||||||
|
'url' => 'required|url',
|
||||||
|
'status' => 'required|string|in:up,down,maintenance',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('modules', function (Blueprint $table) {
|
||||||
|
//
|
||||||
|
$table->enum('status', ['up', 'down', 'maintenance'])->index()->default('down');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('modules', function (Blueprint $table) {
|
||||||
|
//
|
||||||
|
|
||||||
|
$table->dropColumn('status');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
@ -3,9 +3,9 @@
|
|||||||
@section('title', '新建模块')
|
@section('title', '新建模块')
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<h3>新建模块</h3>
|
<h3>新建模块</h3>
|
||||||
|
|
||||||
<form method="POST" action="{{ route('admin.modules.store')}}">
|
<form method="POST" action="{{ route('admin.modules.store')}}">
|
||||||
@csrf
|
@csrf
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@ -23,7 +23,17 @@
|
|||||||
<input type="text" class="form-control" id="url" name="url">
|
<input type="text" class="form-control" id="url" name="url">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 选择状态 -->
|
||||||
|
<div class="form-group mt-1">
|
||||||
|
<label for="status">状态</label>
|
||||||
|
<select class="form-control" id="status" name="status">
|
||||||
|
<option value="up">正常</option>
|
||||||
|
<option value="down">异常</option>
|
||||||
|
<option value="maintenance">维护模式</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
<button type="submit" class="btn btn-primary mt-3">提交</button>
|
<button type="submit" class="btn btn-primary mt-3">提交</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@endsection
|
@endsection
|
@ -3,10 +3,10 @@
|
|||||||
@section('title', '模块:' . $module->name)
|
@section('title', '模块:' . $module->name)
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<h3>{{ $module->name }}</h3>
|
<h3>{{ $module->name }}</h3>
|
||||||
<a class="mt-3" href="{{ route('admin.modules.show', $module) }}">查看</a>
|
<a class="mt-3" href="{{ route('admin.modules.show', $module) }}">查看</a>
|
||||||
|
|
||||||
<form method="POST" action="{{ route('admin.modules.update', $module)}}">
|
<form method="POST" action="{{ route('admin.modules.update', $module)}}">
|
||||||
@csrf
|
@csrf
|
||||||
@method('PATCH')
|
@method('PATCH')
|
||||||
|
|
||||||
@ -25,6 +25,15 @@
|
|||||||
<input type="text" class="form-control" id="url" name="url" value="{{ $module->url }}">
|
<input type="text" class="form-control" id="url" name="url" value="{{ $module->url }}">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group mt-1">
|
||||||
|
<label for="status">状态</label>
|
||||||
|
<select class="form-control" id="status" name="status">
|
||||||
|
<option value="up" @if ($module->status === 'up') selected @endif>正常</option>
|
||||||
|
<option value="down" @if ($module->status === 'down') selected @endif>异常</option>
|
||||||
|
<option value="maintenance" @if ($module->status === 'maintenance') selected @endif>维护模式</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-check mt-1">
|
<div class="form-check mt-1">
|
||||||
<input class="form-check-input" type="checkbox" value="1" id="reset_api_token" name="reset_api_token">
|
<input class="form-check-input" type="checkbox" value="1" id="reset_api_token" name="reset_api_token">
|
||||||
<label class="form-check-label" for="reset_api_token">
|
<label class="form-check-label" for="reset_api_token">
|
||||||
@ -33,15 +42,14 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button type="submit" class="btn btn-primary mt-3">提交</button>
|
<button type="submit" class="btn btn-primary mt-3">提交</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
<hr/>
|
<hr />
|
||||||
<form method="POST" action="{{ route('admin.modules.destroy', $module)}}"
|
<form method="POST" action="{{ route('admin.modules.destroy', $module)}}" onsubmit="return confirm('删除后,业务将无法正常进行。')">
|
||||||
onsubmit="return confirm('删除后,业务将无法正常进行。')">
|
|
||||||
@csrf
|
@csrf
|
||||||
@method('DELETE')
|
@method('DELETE')
|
||||||
<button type="submit" class="btn btn-danger">删除</button>
|
<button type="submit" class="btn btn-danger">删除</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@endsection
|
@endsection
|
||||||
|
@ -3,15 +3,16 @@
|
|||||||
@section('title', '模块:' . $module->name)
|
@section('title', '模块:' . $module->name)
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<h3>{{ $module->name }}</h3>
|
<h3>{{ $module->name }}</h3>
|
||||||
<a class="mt-3" href="{{ route('admin.modules.edit', $module) }}">编辑</a>
|
<p>状态: {{ $module->status }}</p>
|
||||||
<h4 class="mt-2">收益</h4>
|
<a class="mt-3" href="{{ route('admin.modules.edit', $module) }}">编辑</a>
|
||||||
<div>
|
<h4 class="mt-2">收益</h4>
|
||||||
<x-module-earning :module="$module"/>
|
<div>
|
||||||
</div>
|
<x-module-earning :module="$module" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<h4 class="mt-2">主机</h4>
|
<h4 class="mt-2">主机</h4>
|
||||||
<div class="overflow-auto">
|
<div class="overflow-auto">
|
||||||
<table class="table table-hover">
|
<table class="table table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<th>ID</th>
|
<th>ID</th>
|
||||||
@ -54,8 +55,8 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- 分页 --}}
|
{{-- 分页 --}}
|
||||||
{{ $hosts->links() }}
|
{{ $hosts->links() }}
|
||||||
@endsection
|
@endsection
|
Loading…
Reference in New Issue
Block a user