Ejemplo n.º 1
0
$app->post('/restaurant', function () use($app) {
    $body = json_decode($app->request->getBody());
    $restaurant = new Restaurant();
    $restaurant->setName($body->name);
    $restaurant->setSpeisekartenUrl($body->speisekarten_url);
    print_r($body);
    if (property_exists($body, 'image_url')) {
        $restaurant->setImageUrl($body->image_url);
    }
    $restaurant->save();
});
$app->get('/participation', function () {
    outputJSON(Participation::getAll());
});
$app->get('/participation/:id', function ($id) {
    outputJSON(Participation::getById($id));
});
$app->post('/participation', function () use($app) {
    $body = json_decode($app->request->getBody());
    $participation = new Participation();
    $participation->setOffer($body->offer);
    $participation->setUser($body->user);
    $participation->setOrder($body->order);
    $participation->save();
});
$app->get('/offer', function () {
    outputJSON(Offer::getAll());
});
$app->get('/offer/:id', function ($id) {
    outputJSON(Offer::getById($id));
});