/** * Действие-обработчик запроса на сохранение сертификата. * * @param StoreCertificatesRequest $request * @param SavesImages $imageSaver * @return \Illuminate\Http\RedirectResponse * @throws \App\Services\Exception */ public function postCreate(StoreCertificatesRequest $request, SavesImages $imageSaver) { $certificate = new Certificate(); $certificate->title = trim($request->title); $certificate->file_name = $imageSaver->save('file_name', 'certificates', 630); $certificate->save(); return redirect()->action('Admin\\CertificatesController@getEdit', array('id' => $certificate->id))->with('success', 'Сертификат успешно сохранен.'); }
function post_create(\App\Http\Requests\CreateRequest $request) { $this->loginOnly(); $size = $request->size; if (!in_array($size, [32, 64, 96, 128, 192, 256, 320, 512, 768, 1024, 1536, 2048, 4096])) { return $this->get_create()->withErrors(['Такой размер не доступен!']); } $rsa = new RSA((int) $size); $rsa->create(['created_at' => date('Y-m-d H:i:s'), 'best_before' => $best_before = (new \DateTime())->add(new \DateInterval('P3Y'))->format('Y-m-d H:i:s'), 'created_by' => 'Центр сертификации CryptDC', 'owner' => ['firstname' => Auth::user()->firstname, 'lastname' => Auth::user()->lastname, 'country' => Auth::user()->country, 'city' => Auth::user()->city, 'email' => Auth::user()->email]]); $cerf = new Certificate(); $cerf->user_id = Auth::user()->id; $cerf->best_before = $best_before; $cerf->name = $request->name; $cerf->description = $request->description; $cerf->public = $request->public; $cerf->size = $request->size; $cerf->rsa = $rsa->serialize(); $cerf->rsa_public = $rsa->getPublic(); $cerf->rsa_private = $rsa->getPrivate(); $cerf->save(); return redirect('/certificates'); }
/** * 增加证件操作 * @author AndyLee <*****@*****.**> */ public function postCreateCertificate(Request $request) { /** * 处理验证类型,要求传入的证照类型必须与配置文件相同 */ $type = ''; $cert_config = Config::get('customer.certificate'); $count = count($cert_config); $i = 0; foreach ($cert_config as $k => $v) { if ($i + 1 === $count) { $type = $type . $k; } else { $type = $type . $k . ','; } $i++; } $input = $request->only('name', 'type', 'number', 'remarks', 'path'); $rules = ['name' => 'required', 'type' => 'required|in:' . $type, 'path' => 'required']; $v = Validator::make($input, $rules); if ($v->fails()) { Session::flash('error', $v->messages()->first()); return redirect()->back(); } $certificate = new Certificate(); $certificate->company_id = Session::get('customer_id'); $certificate->name = $input['name']; $certificate->operator_id = Auth::user()->id; $certificate->certificate_type = $input['type']; $certificate->certificate_number = $input['number']; $certificate->certificate_path = serialize($input['path']); $certificate->remarks = $input['remarks']; $certificate->save(); Session::flash('success', '增加证照完成'); return redirect()->to(action('CertificateController@getCertificates', Session::get('customer_id'))); }
/** * 创建客户(入库) * @author AndyLee <*****@*****.**> */ public function postCompanyDetail() { /** * full_name 公司全称 * name 公司简称 * leader 法人 * registion_type 注册类型 * address 详细地址 * registed_funds 注册资本 * register_time 经营期限开始 * end_time 经营期限结束 * register_number 工商注册号 * registed_funds_type 注册资本类型 * scope 经营范围 * bookkeeper 财务负责人 一般取当前操作员 * contact 联系人 * mobile 手机 * partners 股东信息 */ $input = Input::Only('full_name', 'name', 'registion_type', 'address', 'registed_funds', 'register_time', 'end_time', 'register_number', 'scope', 'import_partners', 'bookkeeper', 'contact', 'mobile', 'partners', 'registed_funds_type', 'leader'); $rules = ['full_name' => 'required', 'name' => 'required', 'registion_type' => 'required', 'address' => 'required', 'registed_funds' => 'required', 'register_time' => 'date', 'end_time' => 'date']; $v = Validator::make($input, $rules); if ($v->fails()) { Session::flash('error', $v->messages()->first()); return Redirect::to(action('CustomerController@getCreate')); } /** * 处理注册资本 * 如"2000.818万美元"; 将返回2000 818 */ preg_match_all("/[x80-xff]+/", $input['registed_funds'], $match); $uuid = Uuid::uuid1(); $company = new Company(); $company->full_name = trim($input['full_name']); $company->user_id = Session::get('company_id'); $company->uuid = $uuid->toString(); $company->bookkeeper = Auth::user()->id; $company->name = trim($input['name']); $company->location = trim($input['address']); $company->registion_type = $input['registion_type']; $company->create_time = time(); /** * 处理公司简称首字母 */ $first_word = mb_substr($input['name'], 0, 1, 'utf-8'); $pinyin = App::make('pinyin'); $order = $pinyin->letter($first_word); $company->order = $order; if (isset($match[0][1])) { $company->registed_funds = $match[0][0] . '.' . $match[0][1]; } else { $company->registed_funds = $match[0][0]; } if (!empty($input['register_time'])) { $company->register_time = strtotime($input['register_time']); } if (!empty($input['end_time'])) { $company->end_time = strtotime($input['end_time']); } if (!empty($input['register_number'])) { $company->register_number = $input['register_number']; } if (!empty($input['scope'])) { $company->scope = $input['scope']; } if (!empty($input['leader'])) { $company->leader = $input['leader']; } if (!empty($input['registed_funds_type'])) { $company->funds_type = $input['registed_funds_type']; } else { $company->funds_type = "人民币"; } $company->operator_id = Auth::user()->id; $company->save(); /** * 如果存在联系人就加入公司联系人列表 */ if (!empty($input['contact']) and !empty($input['mobile'])) { $contact = new Contact(); $contact->company_id = $company->id; $contact->operator_id = Auth::user()->id; $contact->name = trim($input['contact']); $contact->mobile = trim($input['mobile']); $contact->is_default = 1; $contact->save(); } /** * 如果股东信息存在就加入公司股东表 */ if (!empty($input['partners']) and $input['import_partners'] == 1) { $partners = unserialize($input['partners']); /** * 循环获取股东 */ foreach ($partners as $k) { $partner = new Partner(); $partner->company_id = $company->id; $partner->operator_id = Auth::user()->id; $partner->partner_type = $k['C1'] ? $k['C1'] : '境内中国公民'; $partner->name = $k['C2']; $partner->certificate = $k['C3']; $partner->certificate_number = $k['C4'] ? $k['C4'] : ''; if ($k['RN'] === 1) { $post = '董事长'; } else { $post = '董事'; } $partner->post = $post; $partner->save(); } } /** * 初始化证照信息 */ $certs = Config::get('customer.certificate'); foreach ($certs as $k => $v) { foreach ($v as $m) { $certificate = new Certificate(); $certificate->company_id = $company->id; $certificate->operator_id = Auth::user()->id; $certificate->certificate_type = $k; $certificate->certificate_number = ''; $certificate->certificate_path = ''; // $certificate->remarks = $m; $certificate->name = $m; $certificate->save(); } } Session::flash('success', '创建客户公司完成'); return Redirect::to(action('CustomerController@getIndex')); }