public static function updateInvestmentProfile($investmentProfileID, $investmentProfileData)
 {
     global $db;
     // check if exists
     if (InvestmentProfiles::getInvestmentProfile($investmentProfileID)) {
         // update summary
         $summary = array();
         foreach ($investmentProfileData['investmentProfile'] as $fieldName => $field) {
             foreach ($field as $option => $pref) {
                 if ($pref != 'נייטרלי') {
                     $summary[$option] = $pref;
                 }
             }
         }
         $investmentProfileData['summary'] = json_encode($summary);
         $investmentProfileData['investmentProfile'] = json_encode($investmentProfileData['investmentProfile']);
         return $db->update('investmentProfiles', $investmentProfileData, ['id' => $investmentProfileID]);
     }
     return -1;
 }
<?php

$this->respond(['GET', 'POST'], '/create', function ($request, $response, $service, $app) {
    $data = ['investor' => $request->param('investor', ''), 'investmentProfile' => $request->param('investmentProfile', '')];
    $id = InvestmentProfiles::createInvestmentProfile($data);
    if ($id > 0) {
        $response->json(Result::success('InvestmentProfile Created.', ['id' => $id]));
    } else {
        $response->json(Result::error('InvestmentProfile Creation Failed.'));
    }
});
$this->respond(['GET', 'POST'], '/get/[i:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $profileData = InvestmentProfiles::getInvestmentProfile($id);
    $investor = Investors::getInvestorFromProfile($id);
    $result = array("profileData" => $profileData, "investor" => $investor);
    if ($profileData) {
        $response->json(Result::success('', $result));
    } else {
        $response->json(Result::error('InvestmentProfile not found'));
    }
});
$this->respond(['GET', 'POST'], '/edit/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $data = json_decode($request->body(), true);
    $result = InvestmentProfiles::updateInvestmentProfile($id, $data);
    if ($result > 0) {
        $response->json(Result::success('InvestmentProfile Updated.'));
    } elseif ($result === 0) {
        $response->json(Result::success('InvestmentProfile not Updated.'));
    } else {