12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- /**
- * 用户管理
- * @author system
- * @version 1.0
- * @date 2018-05-14 13:25:12
- *
- */
- namespace App\Repositories\Album;
- use App\Repositories\Base\Repository;
- class UserRepository extends Repository {
- public function model() {
- return \App\Models\AlbumUserModel::class;
- }
- public function searchUser(array $search,array $orderby=['id'=>'desc'],$pagesize=10)
- {
- $currentQuery = $this->model;
- if(isset($search['keyword']) && ! empty($search['keyword'])) {
- $keywords = '%' . $search['keyword'] . '%';
- $currentQuery = $currentQuery->where(function ($query) use ($keywords) {
- $query->where('username' , 'like', $keywords)
- ->orwhere('phone', 'like', $keywords)
- ->orwhere('open_id', 'like', $keywords);
- });
- }
- if (isset($search['role']) && ! empty($search['role']) && $search['role'] != -1) {
- $role = $search['role'];
- $currentQuery = $currentQuery->where(function ($query) use ($role) {
- $query->where('role', $role);
- });
- }
- if (isset($search['is_boss']) && ! empty($search['is_boss']) && $search['is_boss'] != -1) {
- $is_boss = $search['is_boss'];
- $currentQuery = $currentQuery->where(function ($query) use ($is_boss) {
- $query->where('is_boss', $is_boss);
- });
- }
- // dd($orderby);
- $currentQuery = $currentQuery->where(function ($query) use ($search) {
- $query->where('store_id',$search['storeid']);
- });
- if($orderby && is_array($orderby)){
- foreach ($orderby AS $field => $value){
- //dd($orderby);
- $currentQuery = $currentQuery -> orderBy($field, $value);
- }
- }
- $currentQuery = $currentQuery->paginate($pagesize);
- return $currentQuery;
- }
-
- }
|