增加 主机管理页面
This commit is contained in:
parent
d8acdce6e2
commit
6f6b586964
@ -23,23 +23,35 @@ public function index(): View
|
|||||||
|
|
||||||
public function renew(Host $host)
|
public function renew(Host $host)
|
||||||
{
|
{
|
||||||
if ($host->renew()) {
|
$price = $host->getRenewPrice();
|
||||||
return back()->with('success', '续费成功,新的到期时间为:'.$host->next_due_at);
|
|
||||||
|
if ($price > auth()->user()->balance) {
|
||||||
|
return back()->with('error', '余额不足,续费需要:' . $price . ' 元,您还需要充值:' . ($price - auth()->user()->balance) . ' 元');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$host->isCycle()) {
|
||||||
|
return back()->with('error', '该主机不是周期性付费,无法续费。');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($host->renew()) {
|
||||||
|
return back()->with('success', '续费成功,新的到期时间为:' . $host->next_due_at . '。');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return back()->with('error', '续费失败,请检查是否有足够的余额。');
|
return back()->with('error', '续费失败,请检查是否有足够的余额。');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the specified resource from storage.
|
* Remove the specified resource from storage.
|
||||||
*
|
*
|
||||||
* @param Host $host
|
* @param Host $host
|
||||||
|
*
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function destroy(Host $host): RedirectResponse
|
public function destroy(Host $host): RedirectResponse
|
||||||
{
|
{
|
||||||
$host->safeDelete();
|
$host->safeDelete();
|
||||||
|
|
||||||
return back()->with('success', '已添加到销毁队列。');
|
return redirect()->route('hosts . index')->with('success', '已添加到删除队列。');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
87
resources/views/hosts/index.blade.php
Normal file
87
resources/views/hosts/index.blade.php
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('title', '主机')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<h3>主机管理</h3>
|
||||||
|
<p>更快捷的管理计费项目。更高级的管理请前往 "仪表盘"。</p>
|
||||||
|
|
||||||
|
<div class="overflow-auto">
|
||||||
|
<table class="table table-hover">
|
||||||
|
<thead>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>模块</th>
|
||||||
|
<th>名称</th>
|
||||||
|
<th>月估算价格</th>
|
||||||
|
<th>状态</th>
|
||||||
|
<th>更新 / 创建 时间</th>
|
||||||
|
<th>操作</th>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
@foreach ($hosts as $host)
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
{{ $host->id }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a>{{ $host->module->name }}</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ $host->name }}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
@if ($host->managed_price !== null)
|
||||||
|
<span class="text-danger">{{ $host->managed_price }} 元</span>
|
||||||
|
@else
|
||||||
|
{{ $host->price }} 元
|
||||||
|
@endif
|
||||||
|
<br/>
|
||||||
|
@if($host->billing_cycle)
|
||||||
|
<x-billing-cycle :cycle="$host->billing_cycle"/>
|
||||||
|
到期时间:{{ $host->next_due_at }}
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<x-host-status :status="$host->status"/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<span class="small">
|
||||||
|
{{ $host->updated_at }}
|
||||||
|
<br/>
|
||||||
|
{{ $host->created_at }}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<form action="{{ route('hosts.destroy', $host) }}" method="post" class="d-inline">
|
||||||
|
@csrf
|
||||||
|
@method('DELETE')
|
||||||
|
|
||||||
|
<button type="submit" class="btn btn-sm btn-danger"
|
||||||
|
onclick="return confirm('删除后,数据将无法找回,也不可回滚更改。')">删除
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
@if($host->billing_cycle)
|
||||||
|
<form action="{{ route('hosts.renew', $host) }}" method="post" class="d-inline">
|
||||||
|
@csrf
|
||||||
|
|
||||||
|
<button type="submit" class="btn btn-sm btn-primary"
|
||||||
|
onclick="return confirm('将续费此主机。')">续费
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- 分页 --}}
|
||||||
|
{{ $hosts->links() }}
|
||||||
|
|
||||||
|
@endsection
|
@ -40,10 +40,13 @@
|
|||||||
@auth('web')
|
@auth('web')
|
||||||
<ul class="navbar-nav me-auto">
|
<ul class="navbar-nav me-auto">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="{{ route('index') }}">密钥管理</a>
|
<a class="nav-link" href="{{ route('index') }}">授权</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="{{ route('balances.index') }}">余额与充值</a>
|
<a class="nav-link" href="{{ route('balances.index') }}">资金</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="{{ route('hosts.index') }}">主机</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="{{ route('transfer') }}">转账</a>
|
<a class="nav-link" href="{{ route('transfer') }}">转账</a>
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
use App\Http\Controllers\Web\Auth\VerificationController;
|
use App\Http\Controllers\Web\Auth\VerificationController;
|
||||||
use App\Http\Controllers\Web\AuthController;
|
use App\Http\Controllers\Web\AuthController;
|
||||||
use App\Http\Controllers\Web\BalanceController;
|
use App\Http\Controllers\Web\BalanceController;
|
||||||
|
use App\Http\Controllers\Web\HostController;
|
||||||
use App\Http\Controllers\Web\RealNameController;
|
use App\Http\Controllers\Web\RealNameController;
|
||||||
use App\Http\Controllers\Web\TransferController;
|
use App\Http\Controllers\Web\TransferController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
@ -57,6 +58,11 @@ function () {
|
|||||||
Route::post('sudo/exit', [AuthController::class, 'exitSudo'])->name('sudo.exit');
|
Route::post('sudo/exit', [AuthController::class, 'exitSudo'])->name('sudo.exit');
|
||||||
/* End 账户区域 */
|
/* End 账户区域 */
|
||||||
|
|
||||||
|
/* Start 主机 */
|
||||||
|
Route::resource('hosts', HostController::class)->only(['index', 'destroy']);
|
||||||
|
Route::post('hosts/{host}/renew', [HostController::class, 'renew'])->name('hosts.renew');
|
||||||
|
/* End 主机 */
|
||||||
|
|
||||||
/* Start 财务 */
|
/* Start 财务 */
|
||||||
Route::get('transactions', [BalanceController::class, 'transactions'])->name('transactions');
|
Route::get('transactions', [BalanceController::class, 'transactions'])->name('transactions');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user