Returns model

@return ActiveRecord
@throws \Exception
427393
protected function getModel()
	{
		if (!$model = $this->owner) {
			throw new \Exception('Model is not been initialized properly.');
		}
		if (!$model instanceof ActiveRecord) {
			throw new \Exception(sprintf('Behavior must be applied to the ActiveRecord model class and it\'s iheritants, the unsupported class provided: `%s`', get_class($model)));
		}

		return $model;
	}
179549
public function getModel()
    {
        $modelData = is_resource($this->model_data)
            ? stream_get_contents($this->model_data)
            : $this->model_data;

        $model = new $this->versionable_type();
        $model->unguard();
        $model->fill(unserialize($modelData));
        $model->exists = true;
        $model->reguard();
        return $model;
    }
231562
public function getCollection($db = null)
    {
        /* @var $modelClass ActiveRecord */
        $modelClass = $this->modelClass;
        if ($db === null) {
            $db = $modelClass::getDb();
        }
        if ($this->from === null) {
            $this->from = $modelClass::collectionName();
        }

        return $db->getFileCollection($this->from);
    }
1297712
public function getModel()
    {
        if (!$this->isLoggedIn()) {
            throw new NotLoggedInException();
        }

        if (isset($this->loggedInUserIdentifier)) {
            try {
                return SolutionSchema::getModel($this->modelClassName, $this->loggedInUserIdentifier);
            } catch (RecordNotFoundException $er) {
                throw new NotLoggedInException();
            }
        }

        throw new NotLoggedInException();
    }
287965
public function getRecordVersions()
    {
        /** @var ActiveRecord $owner */
        $owner = $this->owner;
        return (new Query)
            ->select('action_id')
            ->from($this->auditTableName)
            ->where(['AND',
                'relation_id = (:tableName)::regclass',
                'statement_only = false',
                ['OR', 'action_type = \'INSERT\'', 'action_type = \'UPDATE\''],
                ':primaryKey' => json_encode($owner->getPrimaryKey(true)),
            ], [':tableName' => $owner->tableName()])
            ->orderBy('action_id')
            ->column($owner->getDb());
    }
570166
public function getForeignValue()
    {
        if ($this->ownerKey !== null) {
            $fk = $this->ownerKey;
            return $this->owner->$fk;
        }
        $this->init();
        switch ($this->type) {
            case self::HAS_MANY:
            case self::HAS_ONE:
                return $this->owner->getPrimaryKeyValue();
            case self::BELONGS_TO:
                $fk = $this->foreign->getTableName() . '_' . $this->foreign->getPrimaryKey();
                return $this->owner->$fk;
            default:
                throw new \Exception(sprintf("Relation type '%s' is not supported.", $this->type));
        }
    }
271688
public function getModel()
    {
        if ($this->_model === null && $this->ngRestModelClass !== null) {
            $this->_model = call_user_func_array([$this->ngRestModelClass, 'findOne'], $this->itemIds);
        }
        
        return $this->_model;
    }
216849
protected function _get_stored_data()
    {
        if (!($prim_key = static::table()->primaryKey()) && !$this->storedAttributes) {
            throw new Exception\RuntimeException(
                "Can't find data without primary key nor storedAttributes"
            );
        }
        
        $query = static::none();
        
        if ($prim_key) {
            $query->where('`'.$prim_key.'` = ?', $this->$prim_key);
        } else {
            $model = new static();
            $cols_names = static::table()->columnNames();
            foreach ($this->storedAttributes as $name => $value) {
                if (in_array($name, $cols_names)) {
                    $model->attributes[$name] = $value;
                }
            }
            
            if (!$model->attributes)
                throw new Exception\RuntimeException(
                    "Model rebuilt from storedAttributes failed"
                );
            else
                return $model;
        }
        
        $current = $query->first();
        
        if (!$current)
            throw new Exception\RuntimeException(
                "Row not found in database (searched with storedAttributes)"
            );
        else
            return $current;
    }
895342
public function get()
    {
        $hasFrom = ! is_null($this->query->from);

        // When no from has been specified at this point the developer
        // tries to do a basic where query. In this case we want to use the index
        // path, since the index path is supposed to return collections.
        if (! $hasFrom) {
            $path = $this->model->getPath('index');
            $this->query->from($path);
        }

        $models = $this->getModels();

        return $this->model->newCollection($models);
    }
997541
public function actionIndex()
    {
        $request = \Yii::$app->request;
        if ($request->getIsOptions()) {
            return $this->ResponseOptions($this->verbs()['index']);
        }
        try{
            $searchModel = new UserSearch();
            $dataProvider = $searchModel->search(Yii::$app->request->queryParams);

            return $dataProvider;
        }catch(Exception $e)
        {
            throw new Exception($e);
        }


    }
846694
protected function _model()
    {
        if ($this->_model !== null) {
            return $this->_model;
        }

        $model = 'I18nMessages';
        if (!empty($this->params['model'])) {
            $model = $this->params['model'];
        }

        return $this->_model = TableRegistry::get($model);
    }
897889
protected function findModel()
    {
        $class = $this->model;
        $query = $class::query();

        foreach ($this->input as $key => $value) {
            $where = is_array($value) ? 'whereIn' : 'where';
            $query->$where($key, $value);
        }

        return $query->get();
    }
62587
public function get_model(){
    $args = \func_get_args();
    $die = false;
    foreach ( $args as $a ){
      if ( \is_string($a) ){
        $path = $a;
      }
      else if ( \is_array($a) ){
        $data = $a;
      }
      else if ( \is_bool($a) ){
        $die = $a;
      }
    }
    if ( empty($path) ){
      $path = $this->path;
      if ( ($this->get_mode() === 'dom') && (!defined('BBN_DEFAULT_MODE') || (BBN_DEFAULT_MODE !== 'dom')) ){
        $path .= '/index';
      }
    }
		else if ( strpos($path, './') === 0 ){
			$path = $this->say_dir().substr($path, 1);
		}
    if ( !isset($data) ){
      $data = $this->data;
    }
		$m = $this->mvc->get_model($path, $data, $this);
		if ( \is_object($m) ){
			$m = bbn\x::to_array($m);
		}
    if ( !\is_array($m) ){
			if ( $die ){
				die("$path is an invalid model");
			}
			return [];
    }
    return $m;
	}
1273354
public function getManagedModel()
    {
        if (!isset($this->managedModel) || $this->managedModel === null) {
            throw new ModelAdminException('You have a ModelAdmin which does not have a model assigned to it. ModelAdmins must include a model to manage.', 1);
        }

        return $this->managedModel;
    }
6279
public function current()
    {
        $document = $this->getCursor()->current();

        if ($document instanceof ActiveRecord) {
            $documentToArray = $document->toArray();
            $this->entitySchema = $document->getSchema();
        } else {
            $documentToArray = (array) $document;
        }

        return $this->getAssembler()->assemble(
            $documentToArray,
            $this->entitySchema
        );
    }
1078745
public function getRecord()
    {
        if (!$this->record && $this->form) {
            if ($this->form->getRecord() && is_a($this->form->getRecord(), 'DataObject')) {
                $this->record = $this->form->getRecord();
            } elseif ($this->form->Controller() && $this->form->Controller()->hasMethod('data')
                    && $this->form->Controller()->data() && is_a($this->form->Controller()->data(), 'DataObject')) {
                $this->record = $this->form->Controller()->data();
            }
        }
        return $this->record;
    }
587921
public function save()
    {
        if (!$this->activeRecordCriteriaPrototype) {
            throw new Exception\RuntimeException(sprintf(
                'An Active Record Criteria Prototype must be set prior to calling %s',
                __FUNCTION__
            ));
        }

        if (!$this->getModel()) {
            throw new Exception\RuntimeException(sprintf('A Model must be set prior to calling %s', __FUNCTION__));
        }

        $criteria = $this->activeRecordCriteriaPrototype;
        $criteria->setId($this->getId());
        $result = $this->getModel()->save($criteria, $this);
        return $result;
    }