technologyRule($data); if(!$status) return [$status,$msg]; if($this->isEmpty($data,'id')) return [false,'ID不存在']; $first = Technology::where('title',$data['title'])->where('id','<>',$data['id'])->where('del_time',0)->first(); if(!empty($first))return [false,'名称已存在!']; $model = new Technology(); $model = $model->where('id',$data['id'])->first(); $model->title = $data['title']; $model->process_id = $data['process_id']; $model->save(); return [true,'保存成功!']; } public function technologyAdd($data,$user){ list($status,$msg) = $this->technologyRule($data); if(!$status) return [$status,$msg]; $first = Technology::where('title',$data['title'])->where('del_time',0)->first(); if(!empty($first))return [false,'名称已存在!']; $model = new Technology(); $model->title = $data['title']; $model->process_id = $data['process_id']; $model->save(); return [true,'保存成功!']; } public function technologyDel($data){ if($this->isEmpty($data,'id')) return [false,'ID必须!']; Technology::where('id',$data['id'])->update([ 'del_time' => time() ]); return [true,'删除成功']; } public function technologyList($data){ $model = Technology::where('del_time',0)->select('*'); if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%'); $list = $this->limit($model,'',$data); return [200,$list]; } public function technologyRule($data){ if($this->isEmpty($data,'title')) return [false,'名称不能为空!']; if($this->isEmpty($data,'process_id')) return [false,'工序不能为空!']; return [true,'']; } public function technologyCopy($data,$user){ list($status,$msg) = $this->technologyCopyRule($data); if(! $status) return [$status,$msg]; $first = Technology::where('id',$data['id'])->where('del_time',0)->first(); $model = new Technology(); $model->title = $data['title']; $model->process_id = $first->process_id; $model->save(); return [true,'保存成功!']; } public function technologyCopyRule($data){ if($this->isEmpty($data,'id')) return [false,'复制的工序ID不能为空!']; if($this->isEmpty($data,'title')) return [false,'名称不能为空!']; $bool = Technology::where('title',$data['title'])->where('del_time',0)->exists(); if($bool) return [false,'名称已存在!']; return [true,'']; } }