public function store(StoreDocumentRequest $request) { $data = $request->all(); $document = $this->storeService->tracking($data['document_id']); if (!empty($data['zero'])) { $this->orderRepository->create($data); } else { if ($document['status'] == 2) { \DB::beginTransaction(); try { $data['evaluation'] = $this->storeService->evaluation($data); $this->orderRepository->create($data); $this->storeService->care($data['document_id']); \DB::commit(); } catch (\Exception $e) { \DB::rollback(); throw $e; } } else { \DB::beginTransaction(); try { $data['evaluation'] = $this->storeService->evaluation($data); $this->orderRepository->create($data); \DB::commit(); } catch (\Exception $e) { \DB::rollback(); throw $e; } } } Session::put('success', 'Corrigida com sucesso'); return redirect()->route('store.index'); }