From fb8bcdcbe0257fba711504cf9489ad4bcd48aa52 Mon Sep 17 00:00:00 2001 From: tokumeikoi Date: Wed, 24 Nov 2021 13:15:28 +0800 Subject: [PATCH] update: fix user filter --- app/Http/Controllers/Admin/UserController.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 083af7b1..629b804b 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -30,8 +30,9 @@ class UserController extends Controller private function filter(Request $request, $builder) { - if ($request->input('filter')) { - foreach ($request->input('filter') as $filter) { + $filters = $request->input('filter'); + if ($filters) { + foreach ($filters as $k => $filter) { if ($filter['condition'] === '模糊') { $filter['condition'] = 'like'; $filter['value'] = "%{$filter['value']}%"; @@ -40,9 +41,11 @@ class UserController extends Controller $filter['value'] = $filter['value'] * 1073741824; } if ($filter['key'] === 'invite_by_email') { - $user = User::where('email', $filter['value'])->first(); + $user = User::where('email', $filter['condition'], $filter['value'])->first(); $inviteUserId = isset($user->id) ? $user->id : 0; $builder->where('invite_user_id', $inviteUserId); + unset($filters[$k]); + continue; } $builder->where($filter['key'], $filter['condition'], $filter['value']); }