The model owner can submit the model for limit removal in selected states i.e. new,
rejected, frozen or blocked. defined within this method.

@return boolean
170074
public function isSubmittable() {

		return $this->isRegistration() || $this->status == IApproval::STATUS_REJECTED ||
			$this->status == IApproval::STATUS_FROJEN || $this->status == IApproval::STATUS_BLOCKED;
	}
878405
protected function proceedingAllowed(): bool
    {
        if ($this->input->getOption('no-interaction')) {
            return true;
        }

        return $this->getHelper('question')->ask($this->input, $this->output, new ConfirmationQuestion('<question>Are you sure you wish to flush the whole database? (y/n)</question>', false));
    }
1161051
public function delete()
    {
        if (!$this->allow_delete) {
            throw $this->exception('Deleting is not allowed');
        }

        $m = $this->model;
        if (!$m->loaded()) {
            throw $this->exception('Cowardly refusing to delete all records');
        }

        $m->delete();

        return true;
    }
1001211
protected function submitEditCountryState()
    {
        if ($this->isPosted('delete')) {
            $this->deleteCountryState();
        } else if ($this->isPosted('save') && $this->validateEditCountryState()) {
            if (isset($this->data_state['state_id'])) {
                $this->updateCountryState();
            } else {
                $this->addCountryState();
            }
        }
    }
1022714
public function delete()
    {
        if (is_null($this->getKeyName())) {
            throw new Exception('No primary key defined on model.');
        }

        // If the model doesn't exist, there is nothing to delete so we'll just return
        // immediately and not do anything else. Otherwise, we will continue with a
        // deletion process on the model, firing the proper events, and so forth.
        if (!$this->exists) {
            return;
        }

        if ($this->fireModelEvent('deleting') === false) {
            return false;
        }

        // Here, we'll touch the owning models, verifying these timestamps get updated
        // for the models. This will allow any caching to get broken on the parents
        // by the timestamp. Then we will go ahead and delete the model instance.
        $this->touchOwners();

        $this->performDeleteOnModel();

        $this->exists = false;

        // Once the model has been deleted, we will fire off the deleted event so that
        // the developers may hook into post-delete operations. We will then return
        // a boolean true as the delete is presumably successful on the database.
        $this->fireModelEvent('deleted', false);

        return true;
    }
111984
protected function validateLimitSettings()
    {
        $field = 'limit';
        $limit = $this->getSubmitted($field);

        if (!ctype_digit($limit) || strlen($limit) > 3) {
            $this->setErrorInteger($field, $this->translation->text('Limit'));
            return false;
        }

        return true;
    }
654834
public function validateValidItem()
    {
        if (!$this->value) {
            return;
        }

        // load allowed values in values_list
        // @todo Imants: Actually we don't need to load all values from Model in
        //       array, just to check couple of posted values.
        //       Probably we should do SELECT * FROM t WHERE id IN ($values) or
        //       something like that to limit array size and time spent on
        //       parsing all DB records in Model.
        $this->getValueList();

        $values = explode($this->separator, $this->value);
        foreach ($values as $v) {
            if (!isset($this->value_list[$v])) {
                $this->displayFieldError("Value $v is not one of the offered values");

                return $this->validate();
            }
        }
    }
1186126
public function delete()
    {
        if ($this->isNewRecord()) {
            throw new DeleteModelException("New models can't be deleted.");
        }

        $this->beforeDelete();
        $this->raiseEvent("BeforeDelete");

        $this->Deleted = true;
        $this->save();

        $this->afterDelete();
        $this->raiseEvent("AfterDelete");
    }
36292
public function isLockable()
    {
        $controller = $this->getMixer();

        if($controller instanceof ControllerModellable)
        {
            if($this->getModel()->getState()->isUnique())
            {
                $entity = $this->getModel()->fetch();

                if($entity->isLockable()) {
                    return true;
                }
            }
        }

        return false;
    }
411249
public function delete()
    {
        if ($this->request->isPost()) {
            $recordId = StaticFilter::filter(
                'text',
                $this->request->getPost('id')
            );

            $record = call_user_func_array(
                [$this->getModelName(), 'get'],
                [$recordId]
            );

            if (is_null($record)) {
                $this->addWarningMessage(
                    "The {$this->get('modelSingular')} with the provided key ".
                    "does not exists."
                );
            } else {
                if ($record->delete()) {
                    $this->addSuccessMessage(
                        "The {$this->get('modelSingular')} was successfully " .
                        "deleted."
                    );
                }
            }
        }
        return $this->redirect($this->_basePath .'/'.$this->get('modelPlural'));
    }
1127645
public function allowed($providedPermission, Model $entity, $owner = true, $ownerColumn = 'user_id')
    {
        if ($this->isPretendEnabled()) {
            return $this->pretend('allowed');
        }

        if ($owner === true && $entity->{$ownerColumn} == $this->id) {
            return true;
        }

        return $this->isAllowed($providedPermission, $entity);
    }
101290
public function delete()
    {
        if ($this->state === State::PENDING) {
            throw new LogicException('You cannot delete pending models');
        } elseif ($this->state === State::SAVED) {
            $this->state = State::DELETED;
        }

        return $this;
    }
46937
public function postSave()
    {
        if (isset($this->historyLimit) && $this->revisionHistory()->count() >= $this->historyLimit) {
            $LimitReached = true;
        } else {
            $LimitReached = false;
        }
        if (isset($this->revisionCleanup)){
            $RevisionCleanup=$this->revisionCleanup;
        }else{
            $RevisionCleanup=false;
        }

        // check if the model already exists
        if (((!isset($this->revisionEnabled) || $this->revisionEnabled) && $this->updating) && (!$LimitReached || $RevisionCleanup)) {
            // if it does, it means we're updating

            $changes_to_record = $this->changedRevisionableFields();

            $revisions = array();

            foreach ($changes_to_record as $key => $change) {
                $revisions[] = array(
                    'revisionable_type' => $this->getMorphClass(),
                    'revisionable_id' => $this->getKey(),
                    'key' => $key,
                    'old_value' => array_get($this->originalData, $key),
                    'new_value' => $this->updatedData[$key],
                    'user_id' => $this->getSystemUserId(),
                    'created_at' => new \DateTime(),
                    'updated_at' => new \DateTime(),
                );
            }

            if (count($revisions) > 0) {
                if($LimitReached && $RevisionCleanup){
                    $toDelete = $this->revisionHistory()->orderBy('id','asc')->limit(count($revisions))->get();
                    foreach($toDelete as $delete){
                        $delete->delete();
                    }
                }
                $revision = Revisionable::newModel();
                \DB::table($revision->getTable())->insert($revisions);
                \Event::dispatch('revisionable.saved', array('model' => $this, 'revisions' => $revisions));
            }
        }
    }
455794
private function canRetry()
    {
        if ($this->isUnlimitedAttempts()) {
            return true;
        }

        $this->attempts++;

        return $this->attempts < $this->maxAttempts;
    }
818344
public function actionSubmit()
    {
        $rr = new RequestResponse();

        if (\Yii::$app->request->isAjax && !\Yii::$app->request->isPjax) {
            if (\Yii::$app->request->post('sx-model') && \Yii::$app->request->post('sx-model-value')) {
                $modelClass = \Yii::$app->request->post('sx-model');
                $modelValue = \Yii::$app->request->post('sx-model-value');
                /**
                 * @var RelatedElementModel    $modelForm
                 * @var Form2FormSend          $modelFormSend
                 * @var RelatedPropertiesModel $validateModel
                 * @var Form2Form              $modelForm
                 */
                $modelForm = $modelClass::find()->where(['id' => $modelValue])->one();
                $modelFormSend = $modelForm->createModelFormSend();
                $modelFormSend->cms_site_id = \Yii::$app->cms->site->id;
                $modelFormSend->utms = (array)\Yii::$app->seo->utms;
                $modelFormSend->page_url = \Yii::$app->request->referrer;

                $validateModel = $modelFormSend->relatedPropertiesModel;

                $modelFormSend->data_values = $validateModel->toArray($validateModel->attributes());
                $modelFormSend->data_labels = $validateModel->attributeLabels();
                $modelFormSend->emails = $modelForm->emails;
                $modelFormSend->phones = $modelForm->phones;


                if ($validateModel->load(\Yii::$app->request->post()) && $validateModel->validate()) {
                    if ($this->_beforeSave($modelForm, $validateModel, $modelFormSend)) {
                        if (!$modelFormSend->save()) {
                            $rr->success = false;
                            $rr->message = \Yii::t('skeeks/form2/app', 'Failed to send the form');
                            return (array)$rr;
                        }

                        $validateModel->save();
                        $modelFormSend->notify();

                        $this->_afterSave($modelForm, $validateModel, $modelFormSend);

                        $rr->success = true;
                        $rr->message = \Yii::t('skeeks/form2/app', 'Successfully sent');
                    } else {
                        $rr->success = false;
                        $rr->message = \Yii::t('skeeks/form2/app', 'Check the correctness of filling the form fields');
                    }

                } else {
                    $rr->success = false;
                    $rr->message = \Yii::t('skeeks/form2/app', 'Check the correctness of filling the form fields');
                }

                return (array)$rr;
            }
        }
    }
1013305
protected function performDeleteOnModel()
    {
        $results = $this->makeRequest($this->getEndpoint(), 'destroy', [
            $this->getKey()
        ]);

        // Creation failed
        if (!$results) {
            return false;
        }

        return true;
    }
592710
protected function _isPaginationEnabled()
    {
        if (!isset($this->controller->limits) ||
            !isset($this->controller->limits[$this->action]) ||
            !isset($this->controller->limits[$this->action]['default']) ||
            !isset($this->controller->limits[$this->action]['limits'])
        ) {
            return false;
        }

        return true;
    }