I have an MVC project and in my controller file I have a case that evaluates the action I execute, in the delete action I want to place a SweerAlert alert that contains an ok and a cancel that when the ok button is deleted , before using sweerAlert it was normal but without asking, now that I put it in it, it gives me a declaration error of variable id in $ worker-> deleteById ($ id), I will put the piece of code to help me please.
case "eliminar":
{
$alert ='<script>swal({
title: "¿Estás seguro?",
text: "Estás por borrar un registro, este no se podrá recuperar más adelante.",
type: "warning",
showCancelButton: true,
cancelButtonText: "Cancelar",
confirmButtonColor: "#DD6B55",
confirmButtonText: "Continuar",
closeOnConfirm: false
},
function (isConfirm) {
if(isConfirm){
swal({
title: "Eliminado",
text: "Eliminaste el registro.",
showConfirmButton: false,
type: "error",
timer: 800
}, function(){
'. $id= $_GET['id'] .';
'.$trabajador->deleteById($id).';
window.location.href="../Vista/trabajador.php?accion=actualizar";
});
}
else{
window.location.href="../Vista/trabajador.php";
}
});</script>';
break;
}