diff --git a/app/Http/Controllers/Admin/HomeController.php b/app/Http/Controllers/Admin/HomeController.php index 9fe30ca..e2689c3 100644 --- a/app/Http/Controllers/Admin/HomeController.php +++ b/app/Http/Controllers/Admin/HomeController.php @@ -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')); + } } diff --git a/app/Http/Controllers/Admin/HostController.php b/app/Http/Controllers/Admin/HostController.php index 094a9b7..2eb8ced 100644 --- a/app/Http/Controllers/Admin/HostController.php +++ b/app/Http/Controllers/Admin/HostController.php @@ -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')); } diff --git a/app/Http/Controllers/Admin/ModuleController.php b/app/Http/Controllers/Admin/ModuleController.php index 26590b0..c76385b 100644 --- a/app/Http/Controllers/Admin/ModuleController.php +++ b/app/Http/Controllers/Admin/ModuleController.php @@ -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')); } diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index a59efa9..87b3a31 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -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()); diff --git a/resources/views/admin/hosts/index.blade.php b/resources/views/admin/hosts/index.blade.php index f902dae..b1a16f0 100644 --- a/resources/views/admin/hosts/index.blade.php +++ b/resources/views/admin/hosts/index.blade.php @@ -11,6 +11,7 @@ 模块 名称 用户 + 月估算价格 创建时间 更新时间 操作 @@ -34,6 +35,9 @@ {{ $host->user->name }} + + {{ $host->price }} 元 + {{ $host->created_at }} diff --git a/resources/views/admin/modules/show.blade.php b/resources/views/admin/modules/show.blade.php index 264fbe8..8c31055 100644 --- a/resources/views/admin/modules/show.blade.php +++ b/resources/views/admin/modules/show.blade.php @@ -17,6 +17,7 @@ ID 名称 用户 + 月估算价格 创建时间 更新时间 操作 @@ -36,6 +37,9 @@ {{ $host->user->name }} + + {{ $host->price }} 元 + {{ $host->created_at }} diff --git a/resources/views/admin/transactions.blade.php b/resources/views/admin/transactions.blade.php new file mode 100644 index 0000000..10bd00c --- /dev/null +++ b/resources/views/admin/transactions.blade.php @@ -0,0 +1,86 @@ +@extends('layouts.admin') + +@section('title', '交易记录') + +@section('content') +

交易记录

+ + 收入 + 支出 + 转账记录 + +
+ + + + + + + + + + + + + + + + @foreach ($transactions as $t) + + + + + + + + + + + + + + @endforeach + + +
类型与模块支付方式说明用户 ID主机 ID入账支出余额交易时间
+ @if ($t->type === 'payout') + + 支出 + + @elseif($t->type === 'income') + + 收入 + + @endif +   + {{ $t->module_id }} + + + +
+ 筛选 +
+ {{ $t->description }} + + {{ $t->user_id }} +
+ 筛选 +
+ @if ($t->host_id) + {{ $t->host_id }} +
+ 筛选 + @endif +
+ {{ $t->income }} 元 + + {{ $t->outcome }} 元 + + {{ $t->balance ?? $t->balances }} 元 + + {{ $t->created_at }} +
+
+ + {{ $transactions->links() }} +@endsection diff --git a/resources/views/layouts/admin.blade.php b/resources/views/layouts/admin.blade.php index 346aacb..c720874 100644 --- a/resources/views/layouts/admin.blade.php +++ b/resources/views/layouts/admin.blade.php @@ -11,10 +11,10 @@ @yield('title', '管理员') -{{-- --}} -{{-- --}} + {{-- --}} + {{-- --}} - + @vite(['resources/sass/app.scss', 'resources/js/app.js']) @@ -46,6 +46,9 @@ + diff --git a/routes/admin.php b/routes/admin.php index 0bfe01b..9ebbcfa 100644 --- a/routes/admin.php +++ b/routes/admin.php @@ -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'); });