title = $title; $this->action = $action; } // 确认弹窗信息 public function confirm() { return '您确定要'.$this->title.'已选中的商品吗?'; } // 处理请求 public function handle(Request $request) { // 获取选中的文章ID数组 $keys = $this->getKey(); if(empty($keys) || !is_array($keys)){ return $this->response()->error('请选择商品!'); } // 获取请求参数 $action = $request->get('action'); $title = $request->get('title'); $actionWhere = $action == 1 ? 0 : 1 ; $title = $this->title ? $this->title : $title; // 下架处理 $res = GoodsActivityModel::whereIn('id',$keys)->where('on_sale',$actionWhere)->update(['on_sale'=>$action]); if($res){ return $this->response()->success($title.'成功')->refresh(); }else{ return $this->response()->error($title.'失败或已'.$title.'!'); } } // 设置请求参数 public function parameters() { return [ 'action' => $this->action, 'title' => $this->title, ]; } }