Commit b052b96e authored by gxx's avatar gxx

user 模糊查询

parent 65a6c1a6
...@@ -17,5 +17,5 @@ interface UserServiceContract ...@@ -17,5 +17,5 @@ interface UserServiceContract
public function update($id,$phone,$user_name,$real_name,$gender,$email,$head_icon); public function update($id,$phone,$user_name,$real_name,$gender,$email,$head_icon);
// public function simpleSearch(); public function simpleSearch($search_content,$page);
} }
\ No newline at end of file
...@@ -84,16 +84,13 @@ class UserController extends Controller ...@@ -84,16 +84,13 @@ class UserController extends Controller
public function simpleSearch(Request $request) public function simpleSearch(Request $request)
{ {
$content = $request->search; $search_content = $request->search;
$user_name = User::where('user_name','like','%'.$content.'%')->get(); $page = 1;
$phone = User::where('phone','like','%'.$content.'%')->get();
$email = User::where('email','like','%'.$content.'%')->get();
$result = $this->mUser->simpleSearch($search_content,$page);
$result = [$user_name,$phone,$email]; return view('admin/usertables',compact('result'));
dd($result);
} }
} }
...@@ -18,6 +18,25 @@ class UserService implements UserServiceContract ...@@ -18,6 +18,25 @@ class UserService implements UserServiceContract
{ {
public function simpleSearch($search_content,$page)
{
$user_name = User::where('user_name','like','%'.$search_content.'%')->paginate($page);
$phone = User::where('phone','like','%'.$search_content.'%')->paginate($page);
$email = User::where('email','like','%'.$search_content.'%')->paginate($page);
if (count($user_name) > 0){
return $user_name;
}
if (count($phone) > 0){
return $phone;
}
if (count($email) > 0){
return $email;
}
$result = null;
return $result;
}
public function getAll($page) public function getAll($page)
{ {
......
...@@ -69,6 +69,19 @@ ...@@ -69,6 +69,19 @@
</tr> </tr>
</thead> </thead>
@if($result == null)
<tbody>
<tr>
<td colspan="9" style="text-align: center;color: red"> 数据暂无 </td>
</tr>
</tbody>
</table>
@else
@foreach($result as $value) @foreach($result as $value)
...@@ -103,6 +116,7 @@ ...@@ -103,6 +116,7 @@
</div> </div>
<!-- /.row --> <!-- /.row -->
</section> </section>
@endif
@endsection @endsection
\ No newline at end of file
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