Exemplo n.º 1
0
$app->get('/login', function () use($user, $app) {
    $user->checkLogin();
});
$app->get('/logout', function () use($user, $app) {
    $user->logout();
});
$app->post('/brands', function () use($brand, $app) {
    if (isset($_SESSION['app']) && isset($_COOKIE['app'])) {
        $brand->newBrand();
    } else {
        echo "<script>window.location='../../'</script>";
    }
});
$app->post('/brands/updateImage', function () use($brand, $app) {
    if (isset($_SESSION['app']) && isset($_COOKIE['app'])) {
        $brand->updateImage();
    } else {
        echo "<script>window.location='../../'</script>";
    }
});
// GET
$app->get('/brands', function () use($brand) {
    $brand->getBrands();
});
$app->get('/brands/:id', function ($id) use($brand) {
    $brand->getBrand($id);
});
$app->delete('/brands/:id', function ($id) use($brand) {
    if (isset($_SESSION['app']) && isset($_COOKIE['app'])) {
        $brand->delete($id);
    } else {