dyjh 6 年之前
父节点
当前提交
41603a8931

+ 2 - 1
app/Http/Controllers/Admin/Album/AgentController.php

@@ -29,7 +29,8 @@ class AgentController extends Controller
 
 
     function index(Request $request) {
     function index(Request $request) {
         $search['keyword'] = $request->input('keyword');
         $search['keyword'] = $request->input('keyword');
-        $query = $this->repository->pushCriteria(new AgentWhere($search,$this->getStoreId()));
+        $search['status'] = $request->input('status');
+        $query = $this->repository->pushCriteria(new AgentWhere($search, $this->getStoreId()));
 
 
         if(isset($request['sort_field']) && $request['sort_field'] && isset($request['sort_field_by'])) {
         if(isset($request['sort_field']) && $request['sort_field'] && isset($request['sort_field_by'])) {
         $query = $query->pushCriteria(new OrderBy($request['sort_field'],$request['sort_field_by']));
         $query = $query->pushCriteria(new OrderBy($request['sort_field'],$request['sort_field_by']));

+ 4 - 0
app/Models/AlbumAgentModel.php

@@ -61,4 +61,8 @@ class AlbumAgentModel extends BaseModel
         'share_times'
         'share_times'
     ];
     ];
 
 
+    public function user()
+    {
+        return $this->belongsTo('App\Models\AlbumUserModel', 'user_id');
+    }
 }
 }

+ 19 - 6
app/Repositories/Album/Criteria/AgentWhere.php

@@ -23,7 +23,7 @@ class AgentWhere extends Criteria {
      * @param array $search
      * @param array $search
      *
      *
      */
      */
-    public function __construct(array $search,int $store_id)
+    public function __construct(array $search, int $store_id)
     {
     {
         $this->search = $search;
         $this->search = $search;
         $this->store_id = $store_id;
         $this->store_id = $store_id;
@@ -36,17 +36,30 @@ class AgentWhere extends Criteria {
      */
      */
     public function apply($model, Repository $repository)
     public function apply($model, Repository $repository)
     {
     {
-        if(isset($this->search['keyword']) && $this->search['keyword']) {
-            $keyword = '%'.$this->search['keyword'].'%';
+        if (isset($this->search['keyword']) && $this->search['keyword']) {
+            $keyword = '%' . $this->search['keyword'] . '%';
             $model = $model->where([['name','like',$keyword],['store_id',$this->store_id]])
             $model = $model->where([['name','like',$keyword],['store_id',$this->store_id]])
                 ->orwhere([['id','like',$keyword],['store_id',$this->store_id]])
                 ->orwhere([['id','like',$keyword],['store_id',$this->store_id]])
                 ->orwhere([['address','like',$keyword],['store_id',$this->store_id]])
                 ->orwhere([['address','like',$keyword],['store_id',$this->store_id]])
                 ->orwhere([['phone','like',$keyword],['store_id',$this->store_id]]);
                 ->orwhere([['phone','like',$keyword],['store_id',$this->store_id]]);
-        } else if(isset($this->search['updated_at']) && $this->search['updated_at']) {
-            $model = $model->where('updated_at',$this->search['updated_at']);
         } else {
         } else {
-            $model = $model->where([['store_id',$this->store_id]]);
+            $model = $model->where([['store_id', $this->store_id]]);
         }
         }
+        if (isset($this->search['status']) && $this->search['status']) {
+            $status = $this->search['status'];
+            $model = $model->whereHas('user', function ($model) use ($status) {
+                if ($status == 3) {
+                    $model->where('is_boss', 1);
+                }
+            })->with(['a:nickname,a:is_boss']);
+            if ($status == 2) {
+                $model = $model->where([['status', 1]]);
+            }
+            if ($status == 1) {
+                $model = $model->where([['status', 0]]);
+            }
+        }
+
 
 
         return $model;
         return $model;
     }
     }

+ 4 - 1
resources/views/admin/album/agent/index.blade.php

@@ -26,7 +26,10 @@
 				        </div>
 				        </div>
 				        </form>
 				        </form>
 						<div class="col-sm-1 pull-left">
 						<div class="col-sm-1 pull-left">
-							<a href="{{ U('Album/Agent/create')}}" class="btn btn-sm btn-primary pull-left">添加</a>
+							<a href="{{ U('Album/Agent/index', ['status' => 0])}}" class="btn btn-sm btn-primary pull-left">全部</a>
+							<a href="{{ U('Album/Agent/index', ['status' => 1])}}" class="btn btn-sm btn-primary pull-left">已审核</a>
+							<a href="{{ U('Album/Agent/index', ['status' => 2])}}" class="btn btn-sm btn-primary pull-left">未审核</a>
+							<a href="{{ U('Album/Agent/index', ['status' => 3])}}" class="btn btn-sm btn-primary pull-left">BOSS</a>
 						</div>
 						</div>
 						{{--@if(role('Album/Agent/create'))
 						{{--@if(role('Album/Agent/create'))
     					<div class="col-sm-3 pull-right">
     					<div class="col-sm-3 pull-right">