Commit 8ae710f8 by 杨昕

优化用户列表

parent eae26344
Pipeline #9903 passed with stages
in 31 seconds
...@@ -38,9 +38,10 @@ class LoginController extends Controller ...@@ -38,9 +38,10 @@ class LoginController extends Controller
} }
$user = DB::connection('mongodb') //选择使用mongodb $user = DB::connection('mongodb') //选择使用mongodb
->collection('users')->where('name',$request->name)->where('user_type',1)->first(); ->collection('users')->where('name',$request->name)->where("user_type",1)->first();
if ($user){
if (!empty($user)){
if ($user['password'] == md5($request->password)){ if ($user['password'] == md5($request->password)){
$result = true; $result = true;
......
...@@ -20,7 +20,7 @@ class UserModel extends Eloquent ...@@ -20,7 +20,7 @@ class UserModel extends Eloquent
/* /*
* 获取用户列表 * 获取用户列表
*/ */
public static function getUserList(){ public static function getUserList($request){
try{ try{
...@@ -40,13 +40,16 @@ class UserModel extends Eloquent ...@@ -40,13 +40,16 @@ class UserModel extends Eloquent
// } // }
// die; // die;
$where = [];
if ($request->name){
$where['name'] = $request->name;
}
$users = DB::connection('mongodb')->collection('users') $users = DB::connection('mongodb')->collection('users')->where($where)
->paginate(10); ->paginate(10);
// dd($users);die;
foreach ( $users as $user){ foreach ( $users as $user){
$idArr = ($user['_id'])->jsonSerialize(); $idArr = ($user['_id'])->jsonSerialize();
$user['_id'] = $idArr['$oid']; $user['_id'] = $idArr['$oid'];
......
...@@ -41,9 +41,9 @@ ...@@ -41,9 +41,9 @@
</button> </button>
<form> <form>
<input type="text" name="name" class="form-input" placeholder="用户名称" value="{{$name}}"> <input type="text" name="name" class="form-input" placeholder="请输入用户名称" value="{{$name}}">
<input id="endDate" width="312" class="form-input" /> {{--<input id="endDate" width="312" class="form-input" />--}}
<button type="submit" class="btn btn-primary">搜索</button> <button type="submit" class="btn btn-primary">搜索</button>
</form> </form>
{{--<span style="display: inline-block;height: 40px;line-height: 40px; float: right">共{{$users->total()}}条</span>--}} {{--<span style="display: inline-block;height: 40px;line-height: 40px; float: right">共{{$users->total()}}条</span>--}}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment