arreglo eliminacion plan2

master
Christian Dacid Sullca Puma 2022-10-27 21:05:10 -05:00
parent 0682f9c375
commit d2a2614da8
1 changed files with 9 additions and 2 deletions

View File

@ -419,8 +419,15 @@ class PlanController extends Controller
public function deletePlan($id) public function deletePlan($id)
{ {
$id_user = auth()->user(); $id_user = auth()->user();
$plan = plan::find($id);
if (!$plan) {
return response([
"status" => 0,
"message" => "!No se encontro el plan",
], 404);
}
if ($id_user->isCreadorPlan($id) or $id_user->isAdmin()) { if ($id_user->isCreadorPlan($id) or $id_user->isAdmin()) {
$plan = plan::where(["id" => $id, "id_user" => $id_user->id])->first();
$plan->delete(); $plan->delete();
return response([ return response([
"status" => 1, "status" => 1,
@ -429,7 +436,7 @@ class PlanController extends Controller
} else { } else {
return response([ return response([
"status" => 0, "status" => 0,
"message" => "!No se encontro el plan de mejora o no esta autorizado", "message" => "!No esta autorizado par realizar esta accion",
], 404); ], 404);
} }
} }