Set the related model object.

@param \Titon\Model\Model $model
@return $this
4860
public function setRelatedModel(Model $model) {
        $this->_relatedModel = $model;
        $this->setRelatedClass(get_class($model));

        return $this;
    }
647253
public function set(ModelInterface $model, $alias = null)
    {
        $hash = spl_object_hash($model);

        $this->collection[$hash] = &$model;

        if ($alias !== null) {
            $this->byAlias[$model->alias($alias)] = &$this->collection[$hash];
        }

        $this->byEntity[$this->normalizeNamespace($model->entity())] = &$this->collection[$hash];

        return $this;
    }
1041304
public function setModel($model, $foreignKey, $foreignKeyIds)
    {
        $this->model = $model;
        $this->foreignKey = $foreignKey;
        $this->foreignKeyIds = array_wrap($foreignKeyIds);

        $this->message = "Integrity constraint violation [{$model}] where $foreignKey in (".implode(', ', $foreignKeyIds).')';

        return $this;
    }
564347
public function setAssociationCounts(Model $model) {
        $counts = array();

        foreach (array($model->hasMany, $model->hasAndBelongsToMany) as $property) {
            foreach ($property as $alias => $assoc) {
                $class = isset($assoc['with']) ? $assoc['with'] : $assoc['className'];

                $counts[$alias] = Admin::introspectModel($class)->find('count', array(
                    'conditions' => array($assoc['foreignKey'] => $model->id),
                    'contain' => false
                ));
            }
        }

        $this->Controller->set('counts', $counts);
    }
408558
public function unlink(Model $model) {
        $this->getRelation($this->getAlias(get_class($model)))->unlink($model);

        return $this;
    }
289284
public function associate(Model $model)
    {
        $this->parent->setAttribute($this->foreignKey, $model->getAttribute($this->otherKey));

        return $this->parent->setRelation($this->relation, $model);
    }
1136678
protected function setForeignAttributesForCreate(Model $model)
    {
        $foreignKey = $this->getForeignKeyName();
        $parentKeyValue = $this->getParentKey();
        if (is_array($foreignKey)) { //Check for multi-columns relationship
            foreach ($foreignKey as $index => $key) {
                $model->setAttribute($key, $parentKeyValue[$index]);
            }
        } else {
            parent::setForeignAttributesForCreate($model);
        }
    }
881428
public function model(Model $model)
    {
        // Check if the model is searchable before setting the query builder model
        $traits = class_uses_recursive(get_class($model));

        if (!isset($traits[Searchable::class])) {
            throw new InvalidArgumentException(get_class($model).' does not use the searchable trait');
        }

        $this->model = $model;

        return $this;
    }
1081700
public function setModel($model)
	{
		$this->model = $model;
		
		$this->from($this->model->metableTable() . ' AS m');
		
		if ($this->model->metableTableSoftDeletes()) {
			$this->whereNull('m.' . $this->model->getDeletedAtColumn());
		}
		
		return $this;
	}
1221983
public function addToRemoveModel(ModelInterface $model): RelatedModelManipulationStack
    {
        $this->toRemoveModels[$model->getId()] = $model;

        return $this;
    }
916288
protected function setModels($models): self
    {
        // We can not use the collect() helper here, since we require this
        // to be an Eloquent Collection
        $this->models = $models instanceof EloquentCollection
            ? $models
            : new EloquentCollection($models);

        return $this;
    }
670530
public function createFromModel(Model $model)
    {
        $this->model = $model;
        $this->query = $this->model->newQuery();

        return $this;
    }
467451
protected function setForeignAttributesForCreate(Model $model)
    {
        $model->{$this->getForeignKeyName()} = $this->getParentKey();

        $model->{$this->getMorphType()} = $this->morphClass;
    }
1319445
public function associate($model)
    {
        $ownerKey = $model instanceof Model ? $model->getAttribute($this->ownerKey) : $model;

        $this->child->setAttribute($this->foreignKey, $ownerKey);

        if ($model instanceof Model) {
            $this->child->setRelation($this->relationName, $model);
        } elseif ($this->child->isDirty($this->foreignKey)) {
            $this->child->unsetRelation($this->relationName);
        }

        return $this->child;
    }
451913
public function save(Model $model)
    {
        $database = $model->getSourceDB();
        $pkey = $model->getID();

        if ($database === null || $database !== $this->db)
            $this->insert($model);
        else
            $this->update($model);

        return $this;
    }
955303
public function addToPersistModel(ModelInterface $model): RelatedModelManipulationStack
    {
        $this->toPersistModels[$model->getId()] = $model;

        return $this;
    }
866723
public function push(Model $model)
    {
        $this->models[$model->getType()][$model->getId()] = $model;
        return $this;
    }