コード例 #1
0
 /**
  * @param int $id
  * @param Request $request
  * @return Illuminate\Http\JsonResponse
  */
 public function putIndex($id, Request $request)
 {
     $useCase = $this->useCase->find($id);
     if ($useCase) {
         $useCase->id_sistema = $request->input('id_sistema');
         $useCase->descricao = $request->input('descricao');
         $useCase->status = $request->input('status');
         $useCase->save();
         $id_revisao = $request->input('id_revisao');
         $findRevision = $this->revision->find($id_revisao);
         $findRevision->id_dados_revisao = $request->input('id_dados_revisao');
         $findRevision->id_caso_de_uso = $id;
         $findRevision->save();
         $findActor = $this->revisionActors->findByRevision($request->input('id_revisao'));
         $findActor->delete();
         foreach ($request->input('id_ator', []) as $id) {
             $r = new RevisionActors();
             $r->id_dados_revisao = $request->input('id_dados_revisao');
             $r->id_ator = $id;
             $r->id_revisao = $id_revisao;
             $r->save();
         }
     }
     return $this->getJsonResponse($id);
 }
コード例 #2
0
 /**
  * @param int $id
  * @return Illuminate\Http\JsonResponse
  */
 public function deleteIndex($id)
 {
     try {
         $count = $this->revision->findByRevision($id)->count();
         if ($count > 0) {
             throw new \Exception('COULD_NOT_DELETE_REVISION');
         }
         $version = $this->version->find($id);
         if ($version) {
             $version->delete();
         }
         return $this->getJsonResponse($id);
     } catch (\Exception $exception) {
         return $this->getJsonResponse(['data' => $exception->getMessage(), 'error' => true], false);
     }
 }
コード例 #3
0
 /**
  * @param Request $request
  * @return Illuminate\Http\JsonResponse
  */
 public function postIndex(Request $request)
 {
     $useCase = new UseCase();
     $useCase->id_sistema = $request->input('application');
     $useCase->descricao = $request->input('description');
     $useCase->status = $request->input('status');
     $useCase->save();
     $idUseCase = $useCase->id_caso_de_uso;
     $revision = new Revision();
     $revision->id_dados_revisao = $request->input('version');
     $revision->id_caso_de_uso = $idUseCase;
     $revision->save();
     $id_revisao = $revision->id_revisao;
     foreach ($request->input('actor', []) as $actor) {
         $revisionActors = new RevisionActors();
         $revisionActors->id_revisao = $id_revisao;
         $revisionActors->id_ator = $actor;
         $revisionActors->id_dados_revisao = $request->input('version');
         $revisionActors->save();
     }
     return $this->getJsonResponse($idUseCase);
 }
コード例 #4
0
 /**
  * @param int $id
  * @return Illuminate\Http\JsonResponse
  */
 public function getPreview($id, UseCaseRepository $useCaseRepository)
 {
     $revision = new Revision();
     $revisionActors = new RevisionActors();
     $complementary = new \Modules\Api\Models\ComplementarySteps();
     $business = new \Modules\Api\Models\BusinessSteps();
     $reference = new \Modules\Api\Models\ReferenceSteps();
     $result = [];
     $app = new Application();
     $array = $app->where('id_sistema', $id)->get();
     foreach ($array as $application) {
         $u = $useCaseRepository->findByIdSistema($application->id_sistema);
         $a = $u->get()->toArray();
         $result['app'] = $application->toArray();
         foreach ($a as $useCaseMaroto) {
             $arrayU = $u->get()->toArray();
             foreach ($arrayU as $key => $singleUseCase) {
                 $result['app']['useCase'][$key] = $singleUseCase;
                 $revisionA = $revision->findByUseCase($singleUseCase['id_caso_de_uso'])->get()->toArray();
                 foreach ($revisionA as $revisionData) {
                     $result['app']['useCase'][$key]['revision'] = $revisionData;
                     $result['app']['useCase'][$key]['revision']['actors'] = $revisionActors->findActorByRevision($revisionData['id_revisao'])->get()->toArray();
                     $flow = $this->flow->where('id_revisao', $revisionData['id_revisao'])->get()->toArray();
                     $compl = $complementary->findByUseCase($singleUseCase['id_caso_de_uso']);
                     $bus = $business->findByUseCase($singleUseCase['id_caso_de_uso']);
                     $ref = $reference->findByUseCase($singleUseCase['id_caso_de_uso']);
                     $result['app']['useCase'][$key]['revision']['flow'][] = ['complementary' => $compl, 'business' => $bus, 'reference' => $ref];
                 }
             }
         }
     }
     return $this->getJsonResponse($result, false);
 }