Validacion de update plan
This commit is contained in:
parent
6a2285690c
commit
c3026c4fdd
@ -55,7 +55,7 @@ public function createPlan(Request $request){
|
|||||||
|
|
||||||
$id_user = auth()->user()->id;
|
$id_user = auth()->user()->id;
|
||||||
$plan = new plan();
|
$plan = new plan();
|
||||||
|
|
||||||
$plan->id_user = $id_user;
|
$plan->id_user = $id_user;
|
||||||
$plan->id_estandar = $request->estandar_id; //actualizar a estandar_id
|
$plan->id_estandar = $request->estandar_id; //actualizar a estandar_id
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ public function createPlan(Request $request){
|
|||||||
$plan->evaluacion_eficacia = $request->evaluacion_eficacia;
|
$plan->evaluacion_eficacia = $request->evaluacion_eficacia;
|
||||||
$plan->avance = $request->avance;
|
$plan->avance = $request->avance;
|
||||||
$plan->save();
|
$plan->save();
|
||||||
|
|
||||||
$id_plan = $plan->id;
|
$id_plan = $plan->id;
|
||||||
|
|
||||||
foreach($request->fuentes as $fuente){
|
foreach($request->fuentes as $fuente){
|
||||||
@ -123,7 +123,7 @@ public function createPlan(Request $request){
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach($request->responsables as $responsable){
|
foreach($request->responsables as $responsable){
|
||||||
$responsable_aux = new Responsables();
|
$responsable_aux = new Responsables();
|
||||||
$responsable_aux ->nombre = $responsable["nombre"];
|
$responsable_aux ->nombre = $responsable["nombre"];
|
||||||
$responsable_aux ->id_plan = $id_plan;
|
$responsable_aux ->id_plan = $id_plan;
|
||||||
$responsable_aux ->save();
|
$responsable_aux ->save();
|
||||||
@ -138,18 +138,18 @@ public function createPlan(Request $request){
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//falta funcion filtrar por estandares
|
//falta funcion filtrar por estandares
|
||||||
|
|
||||||
public function listPlan(){
|
public function listPlan(){
|
||||||
$id_user = auth()->user()->id;
|
$id_user = auth()->user()->id;
|
||||||
|
|
||||||
$planAll = plan::select('plans.id','plans.nombre', 'plans.codigo','plans.avance','plans.estado','plans.id_user','estandars.name as estandar_name','users.name as user_name')
|
$planAll = plan::select('plans.id','plans.nombre', 'plans.codigo','plans.avance','plans.estado','plans.id_user','estandars.name as estandar_name','users.name as user_name')
|
||||||
->join('estandars', 'plans.id_estandar', '=', 'estandars.id')
|
->join('estandars', 'plans.id_estandar', '=', 'estandars.id')
|
||||||
->join('users', 'plans.id_user', '=', 'users.id')
|
->join('users', 'plans.id_user', '=', 'users.id')
|
||||||
->orderBy('plans.id','asc')
|
->orderBy('plans.id','asc')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
foreach($planAll as $plan){
|
foreach($planAll as $plan){
|
||||||
$plan->esCreador = ($plan->id_user == $id_user)?true:false;
|
$plan->esCreador = ($plan->id_user == $id_user)?true:false;
|
||||||
unset($plan->id_user);
|
unset($plan->id_user);
|
||||||
}
|
}
|
||||||
@ -161,7 +161,18 @@ public function listPlan(){
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updatePlan(Request $request, $id){
|
public function updatePlan(Request $request){
|
||||||
|
$request->validate([
|
||||||
|
"id"=> "required|integer",
|
||||||
|
"nombre"=> "required|max:255",
|
||||||
|
"oportunidad_plan"=> "required|max:255",
|
||||||
|
"semestre_ejecucion"=> "required|max:8",
|
||||||
|
"duracion"=> "required|integer",
|
||||||
|
"estado"=> "required|max:30",
|
||||||
|
"evaluacion_eficacia"=> "required|boolean",
|
||||||
|
"avance"=> "required|integer",
|
||||||
|
]);
|
||||||
|
$id = $request->id;
|
||||||
$id_user = auth()->user()->id;
|
$id_user = auth()->user()->id;
|
||||||
if(plan::where(["id_user"=>$id_user,"id"=>$id])->exists()){
|
if(plan::where(["id_user"=>$id_user,"id"=>$id])->exists()){
|
||||||
$plan = plan::find($id);
|
$plan = plan::find($id);
|
||||||
@ -185,7 +196,6 @@ public function updatePlan(Request $request, $id){
|
|||||||
"message" => "!No se encontro el plan o no esta autorizado",
|
"message" => "!No se encontro el plan o no esta autorizado",
|
||||||
],404);
|
],404);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
Route::get('plan',[PlanController::class,'listPlan']);
|
Route::get('plan',[PlanController::class,'listPlan']);
|
||||||
Route::get('plan/{id}',[PlanController::class,'showPlan']);
|
Route::get('plan/{id}',[PlanController::class,'showPlan']);
|
||||||
Route::delete('plan/{id}',[PlanController::class,'deletePlan']);
|
Route::delete('plan/{id}',[PlanController::class,'deletePlan']);
|
||||||
Route::put('plan/{id}',[PlanController::class,'updatePlan']);
|
Route::put('plan',[PlanController::class,'updatePlan']);
|
||||||
|
|
||||||
//rutas metas
|
//rutas metas
|
||||||
Route::post('meta',[MetasController::class,'create']);
|
Route::post('meta',[MetasController::class,'create']);
|
||||||
|
Loading…
Reference in New Issue
Block a user