Example #1
0
        $object = Address::delete($id);
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
//=============================================================================
//Collection
//=============================================================================
Flight::route('GET /v1/main/collection', function () {
    $company = Flight::request()->query->company;
    try {
        if ($company) {
            $array = Collection::selectByCompany($company);
        } else {
            $array = Collection::selectAll();
        }
        Flight::ok($array);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('GET /v1/main/collection/@id', function ($id) {
    try {
        $object = Collection::select($id);
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('POST /v1/main/collection', function () {