Beispiel #1
0
 /**
  * Show the form for creating a new Sub Product.
  *
  * @param Guard $auth
  * @param       $rp_id
  * @param       $header_id
  * @param       $sp_id
  *
  * @return RedirectResponse
  */
 public function createSubProduct(Guard $auth, $rp_id, $header_id, $sp_id)
 {
     $key = 'clients_' . $header_id;
     if (Cache::has($key)) {
         $clients = Cache::get($key);
         if (!is_null($clients)) {
             $clients = json_decode($clients, true);
             $detail_id = array_shift($clients);
             if (!is_null($detail_id)) {
                 if ($this->headerDeRepository->getHeaderById(decode($header_id))) {
                     $header = $this->headerDeRepository->getModel();
                     $detail = $header->details()->where('id', decode($detail_id))->first();
                     if ($this->repository->getInsuredValue($auth->user(), $sp_id, $header, $detail->client)) {
                         $detail->insured_value = $this->repository->insured_value;
                     }
                     $data = $this->getData();
                     $data['questions'] = $this->retailerProductRepository->getQuestionByProduct(decode($sp_id));
                     $data['plans'] = $this->planRepository->getPlanByProduct(decode($sp_id));
                     return view('vi.sp.create', compact('rp_id', 'header_id', 'sp_id', 'data', 'header', 'detail'))->with(['error_value' => $this->repository->error_value, 'amount_max' => $this->repository->amount_max]);
                 }
             }
         }
     }
     return redirect()->route('de.issuance', ['rp_id' => $rp_id, 'header_id' => $header_id])->with(['error_header' => 'La Poliza de Vida no puede ser creada']);
 }
Beispiel #2
0
 public function planByProduct($rp_id = null)
 {
     return $this->repository->getPlanByProduct($rp_id);
 }