public function show() { try { AuthenticateController::checkUser(null); $trl = TRL::get(); return response()->json(['TRL' => $trl]); } catch (QueryException $e) { return response()->json(['message' => 'server_error', 'exception' => $e->getMessage()], 500); } catch (Exceptions\TokenExpiredException $e) { return response()->json(['token_expired'], $e->getStatusCode()); } catch (Exceptions\TokenInvalidException $e) { return response()->json(['token_invalid'], $e->getStatusCode()); } catch (Exceptions\JWTException $e) { return response()->json(['token_absent'], $e->getStatusCode()); } }
/** * @param Request $request * @return \Illuminate\Http\JsonResponse */ public function addTRL(Request $request) { try { $user = AuthenticateController::checkUser(null); $user->load('Persona'); $proyecto = $user->Persona->Proyecto()->where('Proyecto.id', $request->idProyecto)->first(); if ($proyecto == null) { return response()->json(['message' => 'server_error'], 500); } if ($proyecto->pivot->Owner != 1) { return response()->json(['message' => 'owner_not_matching'], 500); } else { $proyecto->load('TRL'); $trl = TRL::where('id', $request->idTRL)->first(); if ($trl == null) { return response()->json(['message' => 'trl_not_found'], 404); } $proyecto->TRL()->save($trl, $request->Info); $proyecto = Proyecto::find($proyecto->id); $proyecto->load('TRL'); foreach ($proyecto->TRL as $trl) { $data[] = $trl->pivot; } return response()->json(['TRL' => $data]); } } catch (QueryException $e) { return response()->json(['message' => 'server_error', 'exception' => $e->getMessage()], 500); } catch (Exceptions\TokenExpiredException $e) { return response()->json(['token_expired'], $e->getStatusCode()); } catch (Exceptions\TokenInvalidException $e) { return response()->json(['token_invalid'], $e->getStatusCode()); } catch (Exceptions\JWTException $e) { return response()->json(['token_absent'], $e->getStatusCode()); } }