Se terminó de crear los controladores con los métodos CRUD básicos. Lo siguiente es empezar a programar los métodos especificos de cada controlador

This commit is contained in:
Lucho
2026-03-21 09:53:45 -03:00
parent 7b7d81d5d0
commit 6c2c300d6e
95 changed files with 4010 additions and 61 deletions
@@ -0,0 +1,79 @@
<?php
namespace App\Http\Controllers;
use App\Models\Administrador;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class AdministradorController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index(): JsonResponse
{
$items = Administrador::all();
return response()->json([
'success' => true,
'data' => $items,
'message' => 'Registros obtenidos correctamente',
], 200);
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request): JsonResponse
{
$payload = $request->only((new Administrador())->getFillable());
$administrador = Administrador::create($payload);
return response()->json([
'success' => true,
'data' => $administrador,
'message' => 'Registro creado correctamente',
], 201);
}
/**
* Display the specified resource.
*/
public function show(Administrador $administrador): JsonResponse
{
return response()->json([
'success' => true,
'data' => $administrador,
'message' => 'Registro obtenido correctamente',
], 200);
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, Administrador $administrador): JsonResponse
{
$payload = $request->only((new Administrador())->getFillable());
$administrador->update($payload);
return response()->json([
'success' => true,
'data' => $administrador,
'message' => 'Registro actualizado correctamente',
], 200);
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Administrador $administrador): JsonResponse
{
$administrador->delete();
return response()->json([
'success' => true,
'message' => 'Registro eliminado correctamente',
], 200);
}
}