public static function abrirComanda() { try { $venda = $_POST; $MesaDao = new MesaDao(); $VendaTO = new VendaTO(); $MesaVendaDao = new MesaVendaDao(); $MesaVendaTO = new MesaVendaTO(); $VendaTO->__setAll($_POST); $VendaTO->venda_confirmada = 0; $VendaTO->id_status_venda = 1; $id_venda = $MesaDao->abrirComanda($VendaTO); $MesaVendaTO->id_mesa = $venda['id_mesa']; $MesaVendaTO->id_venda = $id_venda; $MesaVendaDao->insertMesaVenda($MesaVendaTO); $mesa = $MesaDao->getResumoMesa($venda['id_mesa']); Flight::response()->status(201)->header('Content-Type', 'application/json')->write(json_encode(array("id_venda" => $id_venda, "mesa" => $mesa)))->send(); } catch (Exception $e) { jsonException($e); } }