public static function executeDelete($id = null) { $modelName = \Supernova\Controller::$model['singular']; $namespace = "\\App\\Model\\" . $modelName; $object = new $namespace(); ${$modelName} = $namespace::findOne(array('where' => array($object->primaryKey => array("=" => $id)))); if (${$modelName}) { ${$modelName}->delete(); \Supernova\Controller::flash(array("message" => __("Delete successful"), "status" => "success")); } else { \Supernova\Controller::flash(array("message" => __("Data does not exist for this Id"), "status" => "danger")); } \Supernova\Controller::redirect(array("prefix" => \Supernova\Core::$elements['prefix'], "controller" => $modelName, "action" => "index")); }
private function onError() { \Supernova\Controller::flash(array("message" => __("Validation error"), "status" => "danger")); return false; }