/** * Show the form for creating a new Client. * * @param string $rp_id * @param string $header_id * @param null $client_id * * @return Response */ public function create($rp_id, $header_id, $client_id = null) { $data = $this->getData($rp_id); $client = new Client(); if (session('client') && session('client') instanceof Client) { $client = session('client'); } elseif (!is_null($client_id) && $this->clientRepository->getClientById(decode($client_id))) { $client = $this->clientRepository->getModel(); } return view('client.de.create', compact('rp_id', 'header_id', 'data', 'client')); }
/** * @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('td.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(); }