public function sendRenewLog(Certificate $certificate) { if (!$this->config->alertRenew) { return false; } $subject = "Certificate " . $certificate->getName() . " was renewed"; $body = "Hello,<br />\n" . " good news everyone! Certificate for " . $certificate->getName() . " was renewed:<br />\n<br />\n" . nl2br($certificate->getLastLog()) . $this->append; return $this->email($subject, $body); }
protected function getLogger(Certificate $certificate) { $logPath = $certificate->getPath() . '/last.log'; @unlink($logPath); $logger = new Logger('issue-new'); $handler = new StreamHandler($logPath); $handler->setFormatter(new LineFormatter("[%datetime%] %level_name%: %message%\n")); $logger->pushHandler($handler); return $logger; }
/** * Get a listing of the Certificates for Profile. * * @return Response */ public function cert_list() { /* try { if (! $user = JWTAuth::parseToken()->authenticate()) { return response()->json(['user_not_found'], 404); } } catch (Tymon\JWTAuth\Exceptions\TokenExpiredException $e) { return response()->json(['token_expired'], $e->getStatusCode()); } catch (Tymon\JWTAuth\Exceptions\TokenInvalidException $e) { return response()->json(['token_invalid'], $e->getStatusCode()); } catch (Tymon\JWTAuth\Exceptions\JWTException $e) { return response()->json(['token_absent'], $e->getStatusCode()); }*/ // the token is valid and we have found the user via the sub claim $certificates = Certificate::select('id', 'slug', 'description')->get(); return response()->json(compact('certificates')); }
/** * Отображает индексную страницу модуля. * * @return \Illuminate\Http\Response */ public function getIndex() { // Статья Model::unguard(); $data['certificates_description'] = Article::firstOrCreate(['type' => 'certificates_description']); Model::reguard(); // Сертификаты $data['certificates'] = Certificate::orderBy('created_at', 'DESC')->paginate(6); return view('marketing.certificates.index', $data); }
function get_certificate($id) { $crf = Certificate::find((int) $id); $certificate = $crf->toArray(); if ($crf->user_id !== Auth::user()->id) { if (!$crf->public) { abort(404); } unset($certificate['public']); unset($certificate['private']); } $info = \App\RSA::unserialize($crf->rsa)->getInfo(); // Доп информация return view('certificate.info', ['certificate' => $certificate, 'info' => $info]); }
private function getCerf() { $rsa = null; if (Request::has('certificate') && Request::input('certificate') != '0' && Auth::check()) { $crf = Certificate::find(Request::input('certificate')); if ($crf && $crf->user->id === Auth::user()->id) { $rsa = $crf->rsaObject(); } else { $errors[] = 'Сертификат не найден!'; } } else { if (Request::has('key')) { $rsa = new RSA(); try { $rsa->set(Request::input('key')); } catch (\Exception $e) { $errors[] = 'Неверный формат сертификата!'; } } } return $rsa; }
/** * 上传证件 * @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); } }
/** * Show the form for creating a new resource. * * @param int $id profile_id * @return Response */ public function create($id) { $profile = Profile::findOrFail($id); $fields = Certificate::lists("description", "id"); return view('profile_certificates.create', compact('profile', 'fields')); }
/** * 列出客户公司信息 * @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); }
/** * Удаление сертификата. * * @param $id * @return \Illuminate\Http\RedirectResponse */ public function getDelete($id) { $certificate = Certificate::find($id); if (empty($certificate)) { abort(404); } // Удаляем изображение File::delete(public_path('assets' . DIRECTORY_SEPARATOR . 'img' . DIRECTORY_SEPARATOR . 'certificates' . DIRECTORY_SEPARATOR . $certificate->file_name)); $certificate->delete(); return redirect()->action('Admin\\CertificatesController@getIndex')->with('success', 'Сертификат успешно удален.'); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $certificate = Certificate::findOrFail($id); $certificate->delete(); return redirect('certificates'); }