[isAllowed description]

@param Model $Model Model using this behavior.
@return boolean
186593
public function isAllowed(Model $Model, $action = 'create') {
		if (false === $Model->requireAuth) {
			return true;
		}

		extract($this->settings[$Model->alias]);

		if (!in_array($action, $perms)) {
			throw new FatalErrorException(__d('common', "No '%s' action defined for controlling '%s' authorization", $action, $Model->name));
		}

		$currentGroup = $this->getCurrentUser($Model, $groups['auth']);
		$currentUser = $this->getCurrentUser($Model, $owner['auth']);

		$current = $Model->getID();

		if ($this->isCustomRole($Model, $action)) {
			return true;
		}

		if (!$Model->exists()) {
			if (
				in_array($action, array('create', 'update'))
				&& empty($Model->data[$Model->alias][$owner['path']])
			) {
				$Model->data[$Model->alias][$owner['path']] = $currentUser;
			}
			return true;
		}

		if ($owner[$action] && $this->isOwner($Model)) {
			return true;
		}

		$find = false;
		$unload = false;

		if (
			empty($Model->activeRecord[$Model->alias][$Model->primaryKey])
			|| $current != $Model->activeRecord[$Model->alias][$Model->primaryKey]
		) {
			$Model->activeRecord = null;
		}

		if (empty($Model->activeRecord)) {
			$find = true;
		} else {
			foreach (array('groups', 'collaborators') as $key) {
				if (false !== ${$key}['allow'] && ${$key}[$action] && !Hash::check($Model->activeRecord, ${$key}['path'])) {
					$find = true;
					break;
				}
			}
		}

		if ($find && !$Model->Behaviors->loaded('Containable')) {
			$Model->Behaviors->load('Containable');
			$unload = true;
		}

		if ($find) {
			$contain = array();
			foreach (array('groups', 'collaborators') as $key) {
				if (false !== ${$key}['allow'] && ${$key}[$action]) {
					$contain[] = str_replace('{n}.', '', ${$key}['path']);
				}
			}

			$Model->requireAuth = false;
			$Model->activeRecord = Hash::merge((array) $Model->activeRecord, $Model->find('first', array(
				'conditions' => array($Model->alias . '.' . $Model->primaryKey => $current),
				'fields' => $Model->alias . '.' . $owner['path'],
				'contain' => $contain,
			)));
			$Model->requireAuth = true;
		}

		if ($unload) {
			$Model->Behaviors->unload('Containable');
		}

		foreach (array('groups', 'collaborators') as $key) {
			if (false !== ${$key}['allow'] && $extract = Hash::extract($Model->activeRecord, ${$key}['path'])) {
				${$key}['allow'] = array_merge(${$key}['allow'], $extract);
			}
		}

		return (
			(!empty($collaborators[$action]) && in_array($currentUser, (array) $collaborators['allow']))
			|| (!empty($groups[$action]) && array_intersect((array) $groups['allow'], (array) $currentGroup))
		);
	}
648793
public static function wasCreatedRecently(Model $model)
    {
        if (isset($model->created_at)) {

            $now = Carbon::now();

            if($model->created_at->lte($now) && $model->created_at->gte($now->subMinutes(static::RECENTLY))) {
                return true;
            }
        }

        return false;
    }
1268144
public function saved($model)
    {
        if (static::syncingDisabledFor($model)) {
            return;
        }

        if (! $model->shouldBeSearchable()) {
            $model->unsearchable();

            return;
        }

        $model->searchable();
    }
898864
public function delete($model)
    {
        if ($model->files) {
            $model->files->each(function (File $file) {
                $file->delete();
            });
        }
        if ($model->delete()) {
            return true;
        }

        return false;
    }
454523
public function checkTableExists($model)
    {
        if (!in_array($model->table, $this->getAuditTables())) {
            $model->addError('table', Yii::t('app', "You've entered an invalid table name."));
            return false;
        }
        return true;
    }
1129534
public function clearCache(Model $model) {
        if ($this->_cached) {
            foreach ($this->_cached as $key => $value) {
                $this->deleteCache($model, $key);
            }
        }

        return Cache::clear(false, $this->settings[$model->alias]['cacheConfig']);
    }
247548
public function delete(Model $model)
    {
        $deleted = $model->delete();

        if ($deleted) {
            app('cache')->flush();
        }

        return $deleted;
    }
479166
public function afterDelete(Model &$model)
    {
        /** @var \T4\Orm\Model $class */
        $class = get_class($model);
        $tableName = $class::getTableName();
        /** @var \T4\Dbal\Connection $connection */
        $connection = $class::getDbConnection();

        $query = (new Query())
            ->delete()
            ->table($tableName)
            ->where('__lft>:lft AND __rgt<:rgt')
            ->params([':lft' => $model->__lft, ':rgt' => $model->__rgt]);
        $connection->execute($query);

        $this->removeFromTreeByLftRgt($connection, $tableName, $model->__lft, $model->__rgt);

        $model->__lft = 0;
        $model->__rgt = 0;
        $model->__lvl = 0;
        $model->__prt = 0;
    }
622325
private function mustBeFiltered(Model $model): bool
    {
        return
            ($this->withHash !== null && $model->hash !== $this->withHash) ||
            ($this->thatNotMigrated && $model->migrated()) ||
            ($this->onlyMigrated && ! $model->migrated())
        ;
    }
1158126
public function hasRelatedKey($key, $model = false)
    {
        if (!$model) {
            $model = $this->model;
        }

        if (($methodBreaker = strpos($key, '.')) !== false) {
            $method = substr($key, 0, $methodBreaker);
            if (method_exists($model, $method)) {
                return true;
            }
        }

        return false;
    }
873437
protected function delete($model)
    {
        $method = $this->methods['delete'];

        if (!method_exists($this->storage, $method) || !is_callable([$this->storage, $method])) {
            throw new DeleteMethodNotFoundException(get_class($this->storage), $method);
        }

        $this->storage->$method($model);

        return true;
    }
558319
public function afterValidate(Model $model) {
		if (!empty($model->validationErrors)){
			$model->data[$model->alias] = $this->runtime[$model->alias]['data'];
		}
		
		return true;
	}
945483
public static function hasRequiredFields($model, $fields)
    {
        foreach ($fields as $column) {
            if (!is_array($column)) {
                if ($column instanceof ActiveField && $model->isAttributeRequired($column->attribute)) {
                    return true;
                }
                continue;
            }

            foreach ($column as $row) {
                if (!is_array($row)) {
                    if ($row instanceof ActiveField && $model->isAttributeRequired($row->attribute)) {
                        return true;
                    }
                    continue;
                }

                if (static::hasRequiredFields($model, $row)) {
                    return true;
                }
            }

        }
        return false;
    }
485273
public function save(Model $model)
    {
        $model->setAttribute($this->getForeignKeyName(), $this->getParentKey());

        return $model->save() ? $model : false;
    }
948933
public function contains(AbstractModel $model)
    {
        foreach ($this->storage as $key => $storedModel) {
            if ($model === $storedModel->getModel()) {
                return true;
            }
        }

        return false;
    }
945173
public function update(Model $model) {

		return $this->_populate(
			$this->_request('put', $this->_getUrl('element', $model->getPrimaryKey()), [
				'json' => $model->getAttributes()
			]),
			false
		);
	}
18065
public function afterDelete(Model $model) {
        if ($this->settings[$model->alias]['events']['onDelete']) {
            $this->resetCache($model, $model->id);
        }

        return true;
    }