改进 显示

This commit is contained in:
iVampireSP.com 2022-11-21 12:50:26 +08:00
parent a0d0dc4b35
commit 7e8b9cd425
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132
9 changed files with 133 additions and 8 deletions

View File

@ -4,6 +4,8 @@
use App\Http\Controllers\Controller;
use App\Models\Module;
use App\Models\Transaction;
use Illuminate\Http\Request;
class HomeController extends Controller
{
@ -13,4 +15,31 @@ public function index()
return view('admin.index', compact('modules'));
}
public function transactions(Request $request)
{
$transactions = new Transaction();
// query
if ($request->has('user_id')) {
$transactions = $transactions->where('user_id', intval($request->input('user_id')));
}
if ($request->has('module_id')) {
$transactions = $transactions->where('module_id', intval($request->input('module_id')));
}
if ($request->has('host_id')) {
$transactions = $transactions->where('host_id', intval($request->input('host_id')));
}
if ($request->has('payment')) {
$transactions = $transactions->where('payment', $request->input('payment'));
}
$transactions = $transactions->latest()->paginate(50);
return view('admin.transactions', compact('transactions'));
}
}

View File

@ -20,7 +20,7 @@ class HostController extends Controller
public function index(Host $host): View
{
$host->load('user');
$hosts = $host->paginate(100);
$hosts = $host->paginate(50);
return view('admin.hosts.index', compact('hosts'));
}

View File

@ -22,7 +22,7 @@ class ModuleController extends Controller
*/
public function index(Module $module): View
{
$modules = $module->paginate(100);
$modules = $module->paginate(50);
return view('admin.modules.index', compact('modules'));
}

View File

@ -12,8 +12,6 @@
class Transaction extends Model
{
// $t = (new App\Models\Transaction)->create(['name' => 1])
const UPDATED_AT = null;
protected $connection = 'mongodb';
@ -53,7 +51,6 @@ class Transaction extends Model
'module_id',
];
public function scopeThisUser($query)
{
return $query->where('user_id', auth()->id());

View File

@ -11,6 +11,7 @@
<th>模块</th>
<th>名称</th>
<th>用户</th>
<th>月估算价格</th>
<th>创建时间</th>
<th>更新时间</th>
<th>操作</th>
@ -34,6 +35,9 @@
<td>
<a href="{{ route('admin.users.edit', $host->user_id) }}"> {{ $host->user->name }}</a>
</td>
<td>
{{ $host->price }}
</td>
<td>
{{ $host->created_at }}
</td>

View File

@ -17,6 +17,7 @@
<th>ID</th>
<th>名称</th>
<th>用户</th>
<th>月估算价格</th>
<th>创建时间</th>
<th>更新时间</th>
<th>操作</th>
@ -36,6 +37,9 @@
<td>
<a href="{{ route('admin.users.edit', $host->user_id) }}"> {{ $host->user->name }}</a>
</td>
<td>
{{ $host->price }}
</td>
<td>
{{ $host->created_at }}
</td>

View File

@ -0,0 +1,86 @@
@extends('layouts.admin')
@section('title', '交易记录')
@section('content')
<h2>交易记录</h2>
<a href="?type=income">收入</a>
<a href="?type=payout">支出</a>
<a href="?payment=transfer">转账记录</a>
<div class="overflow-auto">
<table class="table">
<thead>
<tr>
<th scope="col">类型与模块</th>
<th scope="col">支付方式</th>
<th scope="col">说明</th>
<th scope="col">用户 ID</th>
<th scope="col">主机 ID</th>
<th scope="col">入账</th>
<th scope="col">支出</th>
<th scope="col">余额</th>
<th scope="col">交易时间</th>
</tr>
</thead>
<tbody>
@foreach ($transactions as $t)
<tr>
<td>
@if ($t->type === 'payout')
<span class="text-danger">
支出
</span>
@elseif($t->type === 'income')
<span class="text-success">
收入
</span>
@endif
&nbsp;
<span class="module_name" module="{{ $t->module_id }}">{{ $t->module_id }}</span>
</td>
<td>
<x-payment :payment="$t->payment"></x-payment>
<br/>
<a href="?payment={{ $t->payment }}">筛选</a>
</td>
<td>
{{ $t->description }}
</td>
<td>
<a href="{{ route('admin.users.edit', $t->user_id) }}">{{ $t->user_id }}</a>
<br/>
<a href="?user_id={{ $t->user_id }}">筛选</a>
</td>
<td>
@if ($t->host_id)
<a href="{{ route('admin.hosts.edit', $t->host_id) }}">{{ $t->host_id }}</a>
<br/>
<a href="?host_id={{ $t->host_id }}">筛选</a>
@endif
</td>
<td class="text-success">
{{ $t->income }}
</td>
<td class="text-danger">
{{ $t->outcome }}
</td>
<td>
{{ $t->balance ?? $t->balances }}
</td>
<td>
{{ $t->created_at }}
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
{{ $transactions->links() }}
@endsection

View File

@ -11,10 +11,10 @@
<title>@yield('title', '管理员')</title>
<!-- Fonts -->
{{-- <link rel="dns-prefetch" href="//fonts.gstatic.com"> --}}
{{-- <link href="https://fonts.bunny.net/css?family=Nunito" rel="stylesheet"> --}}
{{-- <link rel="dns-prefetch" href="//fonts.gstatic.com"> --}}
{{-- <link href="https://fonts.bunny.net/css?family=Nunito" rel="stylesheet"> --}}
<!-- Scripts -->
<!-- Scripts -->
@vite(['resources/sass/app.scss', 'resources/js/app.js'])
</head>
@ -46,6 +46,9 @@
<li class="nav-item">
<a class="nav-link" href="{{ route('admin.work-orders.index') }}">工单</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('admin.transactions') }}">交易记录</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('admin.commands') }}">命令速查表</a>
</li>

View File

@ -25,4 +25,6 @@
Route::resource('work-orders', WorkOrderController::class)->only(['index', 'show', 'edit', 'update', 'destroy']);
Route::view('commands', 'admin.commands')->name('commands');
Route::get('transactions', [HomeController::class, 'transactions'])->name('transactions');
});