Exemplo n.º 1
0
    $data['method'] = filter_var($post_data['method'], FILTER_SANITIZE_STRING);
    $mapper = new OrderMapper($this->db);
    $order = $mapper->getOrderById($data['id']);
    $this->logger->info("POST Updating Order " . $order->getId());
    $order->setTotal($data['total']);
    $order->setDate($data['date']);
    $order->setMethod($data['method']);
    $mapper->update($order);
    $response = $response->withRedirect("/index.php/orders");
    return $response;
});
// Delete Order
$app->get('/order/{id}/delete', function ($request, $response, $args) {
    $id = (int) $args['id'];
    $mapper = new OrderMapper($this->db);
    $order = $mapper->getOrderById($id);
    $this->logger->info("Deleting order " . $id);
    $mapper->delete($order);
    $response = $response->withRedirect("/index.php/orders");
    return $response;
});
/**********************DEPENDANTS**********************/
// Dependants
$app->get('/dependants', function ($request, $response, $args) {
    $this->logger->info("Dependants page");
    $mapper = new DependantMapper($this->db);
    $dependants = $mapper->getDependants();
    return $this->renderer->render($response, 'dependant/dependants.phtml', [$args, "dependants" => $dependants]);
});
// New Dependant
$app->get('/dependant/new', function ($request, $response, $args) {