From bd10e380931f39817f18c707909872fbd75ac3e4 Mon Sep 17 00:00:00 2001 From: zhaoxiang <756958008@qq.com> Date: Sat, 22 Jun 2019 00:30:42 +0800 Subject: [PATCH] =?UTF-8?q?modified=20=E7=BB=86=E8=8A=82=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/User.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/application/admin/controller/User.php b/application/admin/controller/User.php index a15ea52..1c08a0e 100644 --- a/application/admin/controller/User.php +++ b/application/admin/controller/User.php @@ -31,22 +31,22 @@ class User extends Base { $keywords = $this->request->get('keywords', ''); $status = $this->request->get('status', ''); - $where = []; - if ($status === '1' || $status === '0') { - $where['status'] = $status; + $obj = new AdminUser(); + if (strlen($status)) { + $obj->where('status', $status); } if ($type) { switch ($type) { case 1: - $where['username'] = ['like', "%{$keywords}%"]; + $obj->whereLike('username', "%{$keywords}%"); break; case 2: - $where['nickname'] = ['like', "%{$keywords}%"]; + $obj->whereLike('nickname', "%{$keywords}%"); break; } } - $listObj = (new AdminUser())->where($where)->order('create_time DESC') + $listObj = $obj->order('create_time DESC') ->paginate($limit, false, ['page' => $start])->each(function($item, $key){ $item->userData; })->toArray();