Returns a new ActiveQuery object. Can be overridden instead of getQuery().
@param \yii\db\ActiveRecord $model
@return \yii\db\ActiveQuery
490319
protected function createQuery($model)
    {
        $query = $model::find();
        if (empty($query->from)) {
            // required by the query authorizer behavior and when model implements ActiveSearchInterface
            $query->from = ['t' => $model->tableName()];
        }
        return $query;
    }
682056
protected function performUpdate(Model $model)
    {
        $data = collect([$this->getIndexColumn($model) => $this->toVector($model)]);

        $query = $this->database
            ->table($model->searchableAs())
            ->where($model->getKeyName(), '=', $model->getKey());

        if (method_exists($model, 'searchableAdditionalArray')) {
            $data = $data->merge($model->searchableAdditionalArray() ?: []);
        }

        if (! $this->isExternalIndex($model) || $query->exists()) {
            return $query->update($data->all());
        }

        return $query->insert(
            $data->merge([
                $model->getKeyName() => $model->getKey(),
            ])->all()
        );
    }
232641
public function getLikedRecord(Model $model): ?Model
    {
        return $this->likes()
                    ->where('liked_by_id', $model->id)
                    ->where('liked_by_type', get_class($model))
                    ->first();
    }
1141883
public function haveRecord($model, $attributes = [])
    {
        /** @var $record \yii\db\ActiveRecord  * */
        $record = \Yii::createObject($model);
        $record->setAttributes($attributes, false);
        $res = $record->save(false);
        if (!$res) {
            $this->fail("Record $model was not saved");
        }
        return $record->primaryKey;
    }
1077456
public static function query($alias = null, $model = null)
    {
        if (!$model) {
            $model = Di::getDefault()->getShared(static::class);
        }

        $query = $model->_di->get('ManaPHP\Db\Query')->setModel($model);
        if ($alias) {
            $query->from(get_class($model), $alias);
        }

        return $query;
    }
651039
public function getBuilder($model)
    {
        // get query as given constraint or create a new query
        $builder = isset($this->builder->constraints) ? $this->builder->constraints : $model->newQuery();

        $builder = $this->handleSoftDeletes($builder, $model);

        $builder = $this->applyWheres($builder);

        $builder = $this->applyOrders($builder);

        return $builder;
    }
571862
public function check($model)
    {
        if ($this->isSubQuery()) {
            return Builder::make($model, $this->property)->check() && Builder::make($model, $this->propertyToCompare)->check();
        }

        switch ($this->operator) {
            case '=':
                return $this->attribute($model, $this->property) === $this->attribute($model, $this->propertyToCompare);
                break;
            case '>=':
                return $this->attribute($model, $this->property) >= $this->attribute($model, $this->propertyToCompare);
                break;
            case '<=':
                return $this->attribute($model, $this->property) <= $this->attribute($model, $this->propertyToCompare);
                break;
            case '<>':
                return $this->attribute($model, $this->property) !== $this->attribute($model, $this->propertyToCompare);
                break;
            case '>':
                return $this->attribute($model, $this->property) > $this->attribute($model, $this->propertyToCompare);
                break;
            case '<':
                return $this->attribute($model, $this->property) < $this->attribute($model, $this->propertyToCompare);
                break;
        }
        throw new BadMethodCallException('Operator not supported: '.$this->operator);
    }
209762
public function newQuery() : QueryBuilder
    {
        $model = $this->container->make($this->getModelName());

        if (!$model instanceof Model) {
            throw new RepositoryException("Class {$this->model()} must be an instance of " . Model::class);
        }

        return $model->newQuery();
    }
874813
public static function getOldModel(Eloquent $model) {
		$class = get_class($model);

		$oldModel = $class::find($model->id);
		if (empty($oldModel)) :
			throw new NoOldModelException("Could not find model with class {$class} and id {$model->id}");
		endif;

		return $oldModel;
	}
475045
public function setModel(Model $model)
    {
        $this->model = $model;

        $this->query->from($model->getTable());

        return $this;
    }
736053
public function update(Model $model)
    {
        $metadata = $model->getMetadata();
        $criteria = $this->getQuery()->getRetrieveCritiera($metadata, $model->getId());
        $update = $this->createUpdateObj($model);

        if (empty($update)) {
            return $model;
        }

        $this->getQuery()->executeUpdate($metadata, $model->getStore(), $criteria, $update);
        return $model;
    }
1061806
public function create(Model $model) {

		return $this->_populate(
			$this->_request('post', $this->_getUrl('collection'), [
				'json' => $model->getAttributes()
			]),
			false
		);
	}
306243
public function model($model)
    {
        #$model = ucfirst($model).'Model';
        $modelPath = self::$instance->app->findModel($model);
        $modelClass = "App\\Model\\".$model;
        $this->model = new $modelClass();
        self::$instance->modelService = new ModelService();
        self::$instance->modelService->initialize(self::$instance->app);
        return $this->model;
        //$appModel->handleModel($controller, $method);
    }
719215
protected function getModelInstanceQuery(Model $model)
    {
        $query = $model->query();

        $this->applyOrderingToModelInstanceQuery($query);
        $this->applyStartAndStopLimitsToQuery($query);

        return $query;
    }
961206
public function register(ActiveRecord $model)
    {
        /* @var $seo Seo */
        $seo = $model->seo;
        if ($seo->title) {
            Yii::$app->seo->setTitle($seo->title);
        }
        if ($seo->h1) {
            Yii::$app->seo->setH1($seo->h1);
        }
        if ($seo->description) {
            Yii::$app->seo->setDescription($seo->description);
        }
        if ($seo->keywords) {
            Yii::$app->seo->setKeywords($seo->keywords);
        }
        if ($seo->text) {
            Yii::$app->seo->setText($seo->text);
        }
        if ($seo->og_image) {
            Yii::$app->seo->setOgImage($seo->og_image);
        }
        if (Yii::$app->has('openGraph')) {
            Yii::$app->openGraph->title = Yii::$app->seo->getTitle();
            if (Yii::$app->seo->getDescription()) {
                Yii::$app->openGraph->description = Yii::$app->seo->getDescription();
            }
            if (Yii::$app->seo->getOgImage()) {
                $image = Module::twigCompile($seo->og_image, [
                    'model' => $model
                ]);
                Yii::$app->openGraph->image = Url::to($image, true);
            }
        }
    }
698366
protected function getModelRecord($model)
    {
        if (!class_exists($model)) {
            throw new ModuleException(__CLASS__, "Model $model does not exist");
        }

        $record = new $model;
        if (!$record instanceof PhalconModel) {
            throw new ModuleException(__CLASS__, "Model $model is not instance of \\Phalcon\\Mvc\\Model");
        }

        return $record;
    }
324946
protected function getModel($model) {
		$args = func_get_args();
		array_shift($args);
		require 'app/models/' . $model . '.php';
       	$class = 'Tadpole\model\\' . $model;
		if(!empty($args)) {
			$modData = new ReflectionClass($class);
			$returnMod = $modData->newInstanceArgs($args);
			return $returnMod;
		} else {
        	$returnMod = new $class;
			return $returnMod;
		}
	}