Пример #1
0
        $res = $app->response();
        $res['Content-Type'] = 'application/json';
        $res->body($sets);
    });
});
$app->group('/set(s)', function () use($app) {
    $app->get('/', function () use($app) {
        $sets = Set::valid()->get();
        $res = $app->response();
        $res['Content-Type'] = 'application/json';
        $res->body($sets);
    });
    $app->get('/:id', function ($id) use($app) {
        //      $set = Set::find($id);
        $ids = explode(';', $id);
        $set = Set::whereIn('id', $ids)->get();
        $res = $app->response();
        $res['Content-Type'] = 'application/json';
        $res->body($set);
    });
    $app->get('/:id/questions', function ($id) use($app) {
        $ids = explode(';', $id);
        $questions = Question::whereIn('set_id', $ids)->get();
        $questions->load('answers');
        $res = $app->response();
        $res['Content-Type'] = 'application/json';
        $res->body($questions);
    });
});
$app->group('/question(s)', function () use($app) {
    $app->get('/', function () use($app) {