update: fix user filter

This commit is contained in:
tokumeikoi 2021-10-16 20:47:27 +08:00
parent cc3e3b3fd1
commit 90211c1018
4 changed files with 10 additions and 11 deletions

View File

@ -19,7 +19,7 @@ class CouponController extends Controller
$current = $request->input('current') ? $request->input('current') : 1; $current = $request->input('current') ? $request->input('current') : 1;
$pageSize = $request->input('pageSize') >= 10 ? $request->input('pageSize') : 10; $pageSize = $request->input('pageSize') >= 10 ? $request->input('pageSize') : 10;
$sortType = in_array($request->input('sort_type'), ['ASC', 'DESC']) ? $request->input('sort_type') : 'DESC'; $sortType = in_array($request->input('sort_type'), ['ASC', 'DESC']) ? $request->input('sort_type') : 'DESC';
$sort = $request->input('sort') ? $request->input('sort') : 'created_at'; $sort = $request->input('sort') ? $request->input('sort') : 'id';
$builder = Coupon::orderBy($sort, $sortType); $builder = Coupon::orderBy($sort, $sortType);
$total = $builder->count(); $total = $builder->count();
$coupons = $builder->forPage($current, $pageSize) $coupons = $builder->forPage($current, $pageSize)

View File

@ -32,18 +32,17 @@ class UserController extends Controller
{ {
if ($request->input('filter')) { if ($request->input('filter')) {
foreach ($request->input('filter') as $filter) { foreach ($request->input('filter') as $filter) {
if ($filter['key'] === 'invite_by_email') { if ($filter['condition'] === '模糊') {
$user = User::where('email', $filter['value'])->first(); $filter['condition'] = 'like';
if (!$user) continue; $filter['value'] = "%{$filter['value']}%";
$builder->where('invite_user_id', $user->id);
continue;
} }
if ($filter['key'] === 'd' || $filter['key'] === 'transfer_enable') { if ($filter['key'] === 'd' || $filter['key'] === 'transfer_enable') {
$filter['value'] = $filter['value'] * 1073741824; $filter['value'] = $filter['value'] * 1073741824;
} }
if ($filter['condition'] === '模糊') { if ($filter['key'] === 'invite_by_email') {
$filter['condition'] = 'like'; $user = User::where('email', $filter['value'])->first();
$filter['value'] = "%{$filter['value']}%"; $inviteUserId = isset($user->id) ? $user->id : 0;
$builder->where('invite_user_id', $inviteUserId);
} }
$builder->where($filter['key'], $filter['condition'], $filter['value']); $builder->where($filter['key'], $filter['condition'], $filter['value']);
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long