// Return result. ApiUtils::returnSimpleMessage($app, $error, $message, $statusCode); } else { // Return error message. ApiUtils::returnError($app, 'UserNotAdmin'); } } catch (Exception $e) { // An exception ocurred. Return an error message. ApiUtils::handleException($app, $e); } }); // Service for update the values of an assistance list. $app->put('/assistanceList', function () use($app) { try { // Verify that the user is logged. if (ApiUtils::isLogged()) { // Get input. $request = $app->request(); $input = json_decode($request->getBody()); $rows = is_object($input) ? get_object_vars($input) : $input; // Update all rows. for ($i = 0; $i < count($rows); $i++) { $entry = Assistance::find($rows[$i]->id); $attributes = is_object($rows[$i]) ? get_object_vars($rows[$i]) : $rows[$i]; $creation = is_object($rows[$i]->creation) ? get_object_vars($rows[$i]->creation) : $rows[$i]->creation; $attributes['creation'] = $creation['date']; if ($entry != null) { $entry->update_attributes($attributes); } } // Return result.