function deleteAction() { $id = AF::get($_POST, 'id', 0); $modelsID = explode(',', $id); $errors = FALSE; foreach ($modelsID as $id) { $model = new Field(); $model->model_uset_id = $this->user->user_id; if ($model->findByPk($id)) { $model->delete($id); } else { $errors = TRUE; } if ($model->getErrors()) { $errors = TRUE; } unset($model); } if (isset($_POST['ajax'])) { AF::setJsonHeaders('json'); if ($errors) { Message::echoJsonError(__('field_not_deleted')); } else { $countE = AF::get($_POST, 'countE', 100000); if (count($modelsID) >= $countE) { $link = AF::link(array('fields' => 'view')); Message::echoJsonRedirect($link); } else { Message::echoJsonSuccess(__('field_deleted')); } } } $this->redirect(); }
Flight::ok($object); } catch (Exception $exception) { Flight::error($exception); } }); Flight::route('PUT /v1/main/field/@id', function ($id) { try { $object = Field::update($id); Flight::ok($object); } catch (Exception $exception) { Flight::error($exception); } }); Flight::route('DELETE /v1/main/field/@id', function ($id) { try { $object = Field::delete($id); Flight::ok($object); } catch (Exception $exception) { Flight::error($exception); } }); //============================================================================= //Geofence //============================================================================= Flight::route('GET /v1/main/geofence', function () { try { $array = Geofence::selectAll(); Flight::ok($array); } catch (Exception $exception) { Flight::error($exception); }