Exemplo n.º 1
0
 /**
  * @param CoverageCreateFormRequest $request
  * @param string                    $rp_id
  * @param string                    $de_id
  *
  * @return mixed
  */
 public function coverageStore(CoverageCreateFormRequest $request, $rp_id, $de_id)
 {
     if (request()->ajax()) {
         if ($this->retailerProductRepository->getRetailerProductById(decode($rp_id)) && $this->headerDeRepository->getHeaderById(decode($de_id)) && $this->clientRepository->getClientById(decode($request->get('client')))) {
             $retailerProduct = $this->retailerProductRepository->getModel();
             $de = $this->headerDeRepository->getModel();
             $client = $this->clientRepository->getModel();
             if ($this->repository->storeCoverage($request, $retailerProduct)) {
                 $header = $this->repository->getModel();
                 Cache::put($header->id, $request->get('rp_de'), 180);
                 return response()->json(['location' => route('au.coverage.edit', ['rp_id' => $rp_id, 'de_id' => $de_id, 'header_id' => encode($header->id)])]);
             }
         }
         return response()->json(['err' => 'Unauthorized action.'], 401);
     }
     return redirect()->back();
 }