companyImgRepository = $companyImgRepository; $this->companyRepository = $companyRepository; $this->taskService = $taskService; $this->memberLogRepository = $memberLogRepository; } public function list($id) { return $this->companyImgRepository->list($id); } /** * 企业风采 * @param $id * @return \Illuminate\Http\JsonResponse|mixed */ public function companyImg($id) { if (!$id) { return response()->json(['status'=>0, 'msg'=>'参数错误!']); } $res = $this->companyImgRepository->getImgInfo($id); $html = view('app.company.ajax.ajax_remark_img', ['res'=>$res])->render(); return response()->json(['status'=>1, 'msg'=>'', 'data'=>$html]); } /** * @param $request * @param $user * @return \Illuminate\Http\JsonResponse * @throws \ErrorException * @throws \Prettus\Validator\Exceptions\ValidatorException */ public function saveImg($images, $user) { $count = $this->companyImgRepository->imgCount(); if ($count >8) { return response()->json(['status'=>0, 'msg'=>'上传图片已达上限','data'=>'']); } $data = []; $data['image'] = $images; $data['company_id'] = $user->id; $data['audit'] = 0; $subsite_id = $this->companyRepository->getCompanyColumn($user->id, ['subsite_id']); $data['subsite_id'] = $subsite_id['subsite_id']; if (false == $res = $this->companyImgRepository->store($data)) { return response()->json(['status'=>0,'msg'=>'保存失败!']); } $dotask = $this->taskService->doTask('20'); $this->memberLogRepository->createLog($user, 1004, []); if ($dotask['code']) { return response()->json(['status'=>1, 'msg'=>'保存成功', 'imgId'=>$res->id,'data'=>$dotask['data']['points'],'path'=>upload_asset($images)]); } else { return response()->json(['status'=>1, 'msg'=>'保存成功', 'imgId'=>$res->id,'data'=>'','path'=>upload_asset($images)]); } } public function saveRemark($request,$user) { $where['id'] = $request->id; $where['company_id'] = $user->id; $data['title'] = $request->remark; if (!$this->companyImgRepository->saveRemark($data, $where)) { return response()->json(['status'=>0, 'msg'=>'保存备注失败!']); } return response()->json(['status'=>1, 'msg'=>'保存备注成功!']); } public function delImg($id,$user) { if (!$id) { return response()->json(['status'=>0, 'msg'=>'参数错误!']); } if (!$this->companyImgRepository->delImg($id,$user->id)) { return response()->json(['status'=>0, 'msg'=>'删除失败!']); } if(!$this->memberLogRepository->createLog($user,1022,$id)){ throw new \Exception("日志记录失败!"); } return response()->json(['status'=>1, 'msg'=>'删除成功!']); } }