Получить модель с алиасом
@param ActiveRecord $model Модель для которой пытаемся найти алиас
@return mixed
559423
public function get(ActiveRecord $model)
    {
        $key = $model::className() . '-' . $model->getPrimaryKey();
        return ArrayHelper::getValue($this->_storage, $key);
    }
256793
private function getAction(Model $Model)
	{
		$isCreate = true;
		$id = null;

		if (isset($Model->data[$Model->alias][$Model->primaryKey]) && !empty($Model->data[$Model->alias][$Model->primaryKey])) {
			$id = $Model->data[$Model->alias][$Model->primaryKey];
		}
		elseif (!empty($Model->id)) {
			$id = $Model->id;
		}

		if (!empty($id)) {
			$isCreate = !$Model->exists($id);
		}

		return $isCreate ? 'create' : 'modify';
	}
224381
protected function getReference(Model $model)
    {
        $reference = $this->getReferenceValue($model);

        return $this->wrapWithLink($reference, $this->getLinkForReferenceModel($model));
    }
1133841
protected function getCleanLog(Model $Model)
	{
		$ds = $Model->getDataSource();
		$queries = array();

		if (method_exists($ds, 'getLog')) {
			$log = $ds->getLog(false, false);
			$diff = Set::diff($log['log'], $this->cachedQueries);

			$this->cachedQueries = $log['log'];

			foreach ($diff as $entry) {
				if (empty($entry['affected'])) {
					continue;
				}

				$queries[] = $entry['query'];
			}
		}

		return $queries;
	}
1135699
public function getQueryModel($model=null, $self=true)
    {
        if (!$model) {
            $model = static::getFirstTable();
        }
        
        if ($model && is_string($model)) {
            $model = preg_replace('/^' . $this->getTablePrefix() . '/', '', $model, 1);
            return static::getTableInfo($model);
        } else {
            return $model ? : ($self ? $this : null);
        }
    }
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;
	}
302072
public function actionSchedulerLog($model, $pk)
    {
        return new ActiveDataProvider([
            'query' => Scheduler::find()->where(['model_class' => $model, 'primary_key' => $pk]),
            'sort'=> ['defaultOrder' => ['schedule_timestamp' => SORT_ASC]],
            'pagination' => false,
        ]);
    }
1304778
public function updateNode($model)
    {
        $this->validate(['model' => $model]);
        
        $query = null;
        
        $data = $this->con->getData($con, $query);
        
        $params = [
            'index' => $this->client->getIndex(),
            'type'  => $model->tableName(),
            'id'    => $data[0][$this->idColumn],
            'body'  => ['doc' => $data[0]]
        ];
        
        $responses = $this->client->getClient()->update($params);
        return $responses['result'];
    }
789625
public function saveEntity(Model $model)
    {
        $cacheKey = $this->cacheKey($model->toArray());
        $this->cache->forget($cacheKey);
        return $model->save();
    }
696965
protected function cloneModel($model) {
		$exempt = method_exists($model, 'getCloneExemptAttributes') ?
			$model->getCloneExemptAttributes() : null;
		$clone = $model->replicate($exempt);
		if ($this->write_connection) $clone->setConnection($this->write_connection);
		return $clone;
	}
945173
public function update(Model $model) {

		return $this->_populate(
			$this->_request('put', $this->_getUrl('element', $model->getPrimaryKey()), [
				'json' => $model->getAttributes()
			]),
			false
		);
	}
1251511
public static function get(Model $model)
    {
        return Mention::where('model_type', get_class($model))
            ->where('model_id', $model->getKey())
            ->get();
    }
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;
    }
797181
protected function reindexModel(Model $model)
    {
        $mapping = $this->option('mapping') ? json_decode(File::get($this->option('mapping')), true) : null;

        $this->info('---> Reindexing ' . get_class($model));

        $model->reindex(
            $this->option('relations'),
            $this->option('batch'),
            $mapping,
            function ($batch)
            {
                $this->info("* Batch ${batch}");
            }
        );
    }
614549
protected function getModuleByModel(Model $model)
    {
        /** @var ModuleManagerInterface $modules */
        $modules = app(ModuleManagerInterface::class);

        return $modules->getByAssociatedClass(get_class($model));
    }
493642
public static function find($model)
    {
        if (property_exists(self::className(), 'instance')) {
            if (static::$instance instanceof static) {
                /**
                 * @var QueryBuilder $instance
                 */
                $instance = static::$instance;
                $instance->setDao(Dao::component())
                    ->setConditions()
                    ->setGroupFields()
                    ->setOrders()
                    ->setLimit()
                    ->setSelect()
                    ->setAsArray();

                return $instance;
            } else {
                $instance = new static($model);
                $instance->is_single = true;
                return (static::$instance = $instance);
            }
        }
        return null;
    }
53248
public static function with($model)
    {
        $data = static::model()->findAll();

        $idKey = null;
        $whereIn = [];
        foreach ($data as $key => $value) {
            $idKey = $value->primaryKey;
            $whereIn[] = $value->{$value->primaryKey};
        }

        $associatedModel = new $model();
        $associatedData = $associatedModel
            ->where(static::getForeignKey(static::model()->tableName), 'IN', implode(',', $whereIn))
            ->findAll();

        $data = static::buildRelations($data, $associatedModel, $associatedData);

        return $data;
    }