Esempio n. 1
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
require 'vendor/autoload.php';
session_start();
$app = new \Slim\Slim(array("debug" => true));
$app->config(array("templates.path" => "views/templates"));
$app->get('/proprietarios', function () use($app) {
    $app->render('proprietarios.php');
});
$app->get('/animais', function () use($app) {
    $animais = Animal::selectAll();
    $app->render('animais.php');
});
/* ====== ROTAS DA API ======== */
$app->group('/api', function () use($app) {
    $app->get('/proprietarios', function () use($app) {
        return OwnerController::getOwners();
    });
    $app->post('/proprietarios', function () use($app) {
        return OwnerController::addOwner($app->request->post());
    });
    $app->get('/proprietario/:id', function ($id) use($app) {
        return OwnerController::getOwner($id);
    });
    $app->delete('/proprietario/:id', function ($id) use($app) {
        return OwnerController::deleteOwner($id);
    });
    $app->get('/animais', function () use($app) {
        return AnimalController::getAnimals();
 public static function getAnimals()
 {
     return static::toJSON(Animal::selectAll());
 }