end point asignar plan de mejora
This commit is contained in:
parent
e7a78d8b68
commit
53761a8389
@ -321,6 +321,36 @@ public function createPlan(Request $request)
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function assignPlan(Request $request)
|
||||||
|
{
|
||||||
|
$id_user = auth()->user();
|
||||||
|
if ($id_user->isAdmin()) {
|
||||||
|
$request->validate([
|
||||||
|
'id_estandar' => 'required|integer|exists:estandars,id',
|
||||||
|
'id_user' => 'required|integer|exists:users,id',
|
||||||
|
'codigo' => [
|
||||||
|
'required',
|
||||||
|
Rule::unique('plans', 'codigo')->where(function ($query) use ($request) {
|
||||||
|
return $query->where('id_estandar', $request->id_estandar);
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
$plan = new plan();
|
||||||
|
$plan->id_user = $request->id_user;
|
||||||
|
$plan->id_estandar = $request->id_estandar;
|
||||||
|
$plan->codigo = $request->codigo;
|
||||||
|
$plan->save();
|
||||||
|
return response([
|
||||||
|
"status" => 1,
|
||||||
|
"message" => "!Plan de mejora asignado exitosamente",
|
||||||
|
], 200);
|
||||||
|
} else {
|
||||||
|
return response([
|
||||||
|
"status" => 0,
|
||||||
|
"message" => "No tiene permisos para realizar esta acción",
|
||||||
|
], 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//confirmar los datos nesesarios
|
//confirmar los datos nesesarios
|
||||||
public function listPlan()
|
public function listPlan()
|
||||||
|
@ -58,6 +58,7 @@
|
|||||||
Route::delete('plan/{id}', [PlanController::class, 'deletePlan']);
|
Route::delete('plan/{id}', [PlanController::class, 'deletePlan']);
|
||||||
Route::put('plan/{id}', [PlanController::class, 'update']);
|
Route::put('plan/{id}', [PlanController::class, 'update']);
|
||||||
Route::get('plans/user', [PlanController::class, 'listPlanUser']);
|
Route::get('plans/user', [PlanController::class, 'listPlanUser']);
|
||||||
|
Route::post('plan/asignar', [PlanController::class, 'assignPlan']);
|
||||||
//Route::put('plan',[PlanController::class,'updatePlan']);
|
//Route::put('plan',[PlanController::class,'updatePlan']);
|
||||||
|
|
||||||
//rutas metas
|
//rutas metas
|
||||||
|
Loading…
Reference in New Issue
Block a user