Пример #1
0
    $id = $request->param('id');
    $assetData = $request->param('assetData');
    $contactsData = $request->param('assetContacts');
    $investorsData = $request->param('assetInvestors');
    $result = Assets::updateAssetInvest($id, $assetData, $contactsData, $investorsData);
    if ($result > 0) {
        $response->json(Result::success('Asset Updated.'));
    } elseif ($result === 0) {
        $response->json(Result::success('Asset not Updated.'));
    } else {
        $response->json(Result::error('Asset not found'));
    }
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $assetResult = Assets::deleteAsset($id);
    Logs::deleteAssetInvestLogs($id);
    Contacts::deleteAssetContacts($id);
    Investors::deleteAssetInvestors($id);
    RentAreas::deleteAssetRentAreas($id);
    RentProcesses::deleteAssetRentProcesses($id);
    if ($assetResult > 0) {
        $response->json(Result::success('Asset Deleted.'));
    } else {
        $response->json(Result::error('Asset not Deleted'));
    }
});
$this->respond(['GET', 'POST'], '/get/all', function ($request, $response, $service, $app) {
    $result = Assets::getAllAssets();
    $response->json(Result::success('', $result));
});