/**
  * 上传证件
  * @param Request $request
  * @return mixed
  * @author AndyLee <*****@*****.**>
  */
 public function postUploadCertificate(Request $request)
 {
     $input = $request->file('file');
     $param = $request->only('name', 'id');
     $rules = array('file' => 'image|max:3000');
     $validation = \Validator::make(['file' => $input], $rules);
     if ($validation->fails()) {
         return \Response::make($validation->errors->first(), 400);
     }
     $extension = $input->getClientOriginalExtension();
     /**
      * 获取公司信息
      */
     $customer = CustomerCompany::find(Session::get('customer_id'));
     /**
      * 设置存储目录
      * 存储目录结构 =  uploads / sha1加密的公司id /客户公司uuid
      */
     $directory = public_path('uploads') . '/' . sha1(Session::get('company_id')) . '/' . $customer->uuid;
     $filename = sha1(time() . time()) . ".{$extension}";
     $upload_success = $input->move($directory, $filename);
     $message = ['file_path' => asset('uploads/' . sha1(Session::get('company_id')) . '/' . $customer->uuid) . '/' . $filename];
     /**
      * 用户相关证件一键上传
      */
     if (!empty($param['name']) and !empty($param['id'])) {
         $param['company_id'] = Session::get('customer_id');
         try {
             $certificate = Certificate::where($param)->firstOrFail();
         } catch (ModelNotFoundException $e) {
             return \Response::json(['state' => 'denied'], 200);
         }
         $certificate->certificate_path = serialize([$message['file_path']]);
         $certificate->save();
     }
     if ($upload_success) {
         $message['status'] = 'success';
         return \Response::json($message, 200);
     } else {
         $message['status'] = 'error';
         return \Response::json($message, 400);
     }
 }
示例#2
0
 /**
  * 列出客户公司信息
  * @param integer $id
  * @return mixed
  * @author AndyLee <*****@*****.**>
  */
 public function getCustomerCompanyInfo($id)
 {
     //       dd( action('PartnerController@getPartner' , 12));
     $contact = Contact::where(['company_id' => Session::get('customer_id'), 'is_default' => 1])->first();
     $type = Config::get('customer.certificate');
     $result = [];
     /**
      * 查询不同的证件上传情况
      */
     foreach ($type as $k => $v) {
         $record = Certificate::where(['company_id' => Session::get('customer_id'), 'certificate_type' => $k])->first();
         if ($record) {
             $result[$k] = 'exist';
         } else {
             $result[$k] = 'empty';
         }
     }
     /**
      * 获取代办事项
      */
     $todo = App\Task::where(['company_id' => Session::get('customer_id'), 'is_finish' => 0])->take(10)->get();
     $company = Company::find(Session::get('customer_id'));
     return view('customer.index.detail')->with('contact', $contact)->with('result', $result)->with('todo', $todo)->with('company', $company);
 }