public function update(Request $request) { if (Auth::check()) { $all = $request->all(); Validator::extend('mobile', function ($attribute, $value, $parameters) { return preg_match('/^1[34578]\\d{9}$/', $value); }); $validator = Validator::make($all, $this->rules); if ($validator->fails()) { $warnings = $validator->messages(); $show_warning = $warnings->first(); return $this->_returnMessageFile($show_warning, 100); } $disk = QiniuStorage::disk('qiniu'); $all['url'] = ''; if (!empty($_FILES["img"]["tmp_name"])) { if ($disk->put(date('Y/m/d') . '/' . md5($_FILES["img"]["name"]), file_get_contents($_FILES["img"]["tmp_name"]))) { $all['url'] = $disk->downloadUrl(date('Y/m/d') . '/' . md5($_FILES["img"]["name"])); } } $user_info = $this->project->getInfo($request->user()->id); if (empty($user_info)) { $insert = $this->project->insertInfo($request->user()->id, $all); if ($insert != 1) { return $this->_returnMessageFile('插入失败', 101); } } else { $update = $this->project->updateInfo($request->user()->id, $all); if ($update != 1) { return $this->_returnMessageFile('更新失败', 101); } } $profile = new Profile(); $prof_info = $profile->getInfo($request->user()->id); if (empty($prof_info)) { $insert = $profile->insertConact($request->user()->id, $all); if ($insert != 1) { return $this->_returnMessageFile('插入失败', 101); } } else { $update = $profile->updateConact($request->user()->id, $all); if ($update != 1) { return $this->_returnMessageFile('更新失败', 101); } } return $this->_returnMessageFile('修改成功', 200); } else { return redirect()->guest('login'); } }