Lista de Narrativas-correcciones

This commit is contained in:
Christian Dacid Sullca Puma 2022-10-17 10:56:03 -05:00
parent 46a5276843
commit 9020aed4af

View File

@ -9,9 +9,11 @@
//edita solo contenido //edita solo contenido
//eliminar //eliminar
// Cabecera endopoint unico // Cabecera endopoint unico
class NarrativasController extends Controller{ class NarrativasController extends Controller
{
public function create(Request $request){ public function create(Request $request)
{
$request->validate([ $request->validate([
"id_estandar" => "required|integer", "id_estandar" => "required|integer",
"semestre" => "required", "semestre" => "required",
@ -28,15 +30,15 @@ public function create(Request $request){
"msg" => "!Narrativa creada exitosamente", "msg" => "!Narrativa creada exitosamente",
"data" => $narrativa, "data" => $narrativa,
]); ]);
} } else {
else{
return response([ return response([
"status" => 0, "status" => 0,
"msg" => "!No se encontro el estandar", "msg" => "!No se encontro el estandar",
], 404); ], 404);
} }
} }
public function update(Request $request){ public function update(Request $request)
{
$request->validate([ $request->validate([
"id" => "required", "id" => "required",
"contenido" => "required", "contenido" => "required",
@ -47,15 +49,15 @@ public function update(Request $request){
"contenido" => $request->contenido, "contenido" => $request->contenido,
]); ]);
return response()->json($narrativa, 200); return response()->json($narrativa, 200);
} } else {
else{
return response([ return response([
"status" => 0, "status" => 0,
"message" => "!No se encontro la narrativa", "message" => "!No se encontro la narrativa",
], 404); ], 404);
} }
} }
public function delete($id){ public function delete($id)
{
if (Narrativa::where("id", $id)->exists()) { if (Narrativa::where("id", $id)->exists()) {
$narrativa = Narrativa::find($id); $narrativa = Narrativa::find($id);
$narrativa->delete(); $narrativa->delete();
@ -63,15 +65,15 @@ public function delete($id){
"status" => 1, "status" => 1,
"message" => "!Narrativa eliminada", "message" => "!Narrativa eliminada",
]); ]);
} } else {
else{
return response([ return response([
"status" => 0, "status" => 0,
"message" => "!No se encontro la narrativa", "message" => "!No se encontro la narrativa",
], 404); ], 404);
} }
} }
public function show($id){ public function show($id)
{
if (Narrativa::where("id", $id)->exists()) { if (Narrativa::where("id", $id)->exists()) {
$narrativa = Narrativa::find($id); $narrativa = Narrativa::find($id);
return response([ return response([
@ -79,19 +81,19 @@ public function show($id){
"message" => "!Narrativa encontrada", "message" => "!Narrativa encontrada",
"data" => $narrativa, "data" => $narrativa,
]); ]);
} } else {
else{
return response([ return response([
"status" => 0, "status" => 0,
"message" => "!No se encontro la narrativa", "message" => "!No se encontro la narrativa",
], 404); ], 404);
} }
} }
public function listNarrativas(){ public function listNarrativas()
$narrativas = Narrativas::all(); {
$narrativas = Narrativa::all();
return response([ return response([
"status" => 1, "status" => 1,
"msg" => "!Lista de Narrativas", "message" => "!Lista de narrativas",
"data" => $narrativas, "data" => $narrativas,
]); ]);
} }