exit; } $app = new Slim(); $app->get('/test', function () { echo "It is running!!!"; }); $app->get('/restaurant', function () { outputJSON(Restaurant::getAll()); }); $app->get('/restaurant/:id', function ($id) { outputJSON(Restaurant::getById($id)); }); $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());
<?php $db = new PDO('mysql:dbname=mittagesser;host=localhost', 'test', 'testpw'); use Bahuma\GHMittagessen\Offer; use Bahuma\GHMittagessen\Participation; use Bahuma\GHMittagessen\Restaurant; use Carbon\Carbon; require_once '../vendor/autoload.php'; // Restaurants $restaurant1 = new Restaurant(); $restaurant1->setName("Bella Italia"); $restaurant1->setSpeisekartenUrl("http://test.de"); $restaurant1->save(); print "Created Restaurant 1 with id " . $restaurant1->getId(); $restaurant2 = new Restaurant(); $restaurant2->setName("Burgerladen"); $restaurant2->setSpeisekartenUrl("http://test2.de"); $restaurant2->save(); print "Created Restaurant 2 with id " . $restaurant2->getId(); // Offers $offer1 = new Offer(); $offer1->setRestaurant($restaurant1->getId()); $offer1->setUser(1); $offer1->setOrderUntil(new Carbon()); $offer1->save(); print "Created Offer 1 at Restaurant 1 with id " . $offer1->getId(); $offer2 = new Offer(); $offer2->setRestaurant($restaurant2->getId()); $offer2->setUser(1); $offer2->setOrderUntil(new Carbon()); $offer2->save();