actas controller update fix
This commit is contained in:
parent
e148efa2bc
commit
453a6f9276
@ -6,13 +6,14 @@
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Models\Acta;
|
use App\Models\Acta;
|
||||||
|
|
||||||
|
|
||||||
class ActaController extends Controller
|
class ActaController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
public function create(Request $request)
|
public function create(Request $request)
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'descripcion' => 'required',
|
'descripcion' => 'required',
|
||||||
'fecha' => 'required',
|
'fecha' => 'required',
|
||||||
'id_estandar' => 'required|exists:estandars,id',
|
'id_estandar' => 'required|exists:estandars,id',
|
||||||
]);
|
]);
|
||||||
@ -26,8 +27,8 @@ public function create(Request $request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$acta = new Acta();
|
$acta = new Acta();
|
||||||
$acta->id_estandar = $request->id_estandar;
|
$acta->id_estandar = $request->id_estandar;
|
||||||
$acta->fecha = $request->fecha;
|
$acta->fecha = $request->fecha;
|
||||||
$acta->descripcion = $request->descripcion;
|
$acta->descripcion = $request->descripcion;
|
||||||
$acta->save();
|
$acta->save();
|
||||||
|
|
||||||
@ -66,15 +67,16 @@ public function listActas()
|
|||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(Request $request, $id)
|
public function update(Request $request)
|
||||||
{
|
{
|
||||||
$request = Validator::make($request->all(), [
|
$request = Validator::make($request->all(), [
|
||||||
|
'id' => 'required|exists:actas,id',
|
||||||
'descripcion' => 'present',
|
'descripcion' => 'present',
|
||||||
'fecha' => 'present',
|
'fecha' => 'present',
|
||||||
'id_estandar' => 'present|exists:estandars,id',
|
'id_estandar' => 'present|exists:estandars,id',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$acta = Acta::find($id);
|
$acta = Acta::find($request->id);
|
||||||
if (!$acta) {
|
if (!$acta) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'success' => false,
|
'success' => false,
|
||||||
|
@ -127,7 +127,7 @@
|
|||||||
//ruta Actas
|
//ruta Actas
|
||||||
Route::post('acta', [ActaController::class, 'create']);
|
Route::post('acta', [ActaController::class, 'create']);
|
||||||
Route::get('acta/{id}', [ActaController::class, 'showActa'])->where('id', '[0-9]+');
|
Route::get('acta/{id}', [ActaController::class, 'showActa'])->where('id', '[0-9]+');
|
||||||
Route::put('acta/{id}', [ActaController::class, 'update'])->where('id', '[0-9]+');
|
Route::put('acta', [ActaController::class, 'update'])->where('id', '[0-9]+');
|
||||||
Route::delete('acta/{id}', [ActaController::class, 'delete'])->where('id', '[0-9]+');
|
Route::delete('acta/{id}', [ActaController::class, 'delete'])->where('id', '[0-9]+');
|
||||||
Route::get('acta', [ActaController::class, 'listActas']);
|
Route::get('acta', [ActaController::class, 'listActas']);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user