with('user'); // 查询条件过滤 if ($request->filled('username')) { $query->where('username', 'like', '%'.$request->input('username').'%'); } if ($request->filled('currency')) { $query->where('currency', $request->input('currency')); } if ($request->filled('source')) { $query->where('source', $request->input('source')); } if ($request->filled('remark')) { $query->where('remark', 'like', '%'.$request->input('remark').'%'); } if ($request->filled('direction')) { if ($request->input('direction') === 'in') { $query->where('amount', '>', 0); } elseif ($request->input('direction') === 'out') { $query->where('amount', '<', 0); } } if ($request->filled('date_start')) { $query->whereDate('created_at', '>=', $request->input('date_start')); } if ($request->filled('date_end')) { $query->whereDate('created_at', '<=', $request->input('date_end')); } // 默认按时间倒序 $logs = $query->latest('id')->paginate(50)->withQueryString(); $allSources = CurrencySource::cases(); return view('admin.currency-logs.index', compact('logs', 'allSources')); } }