Ignore the given model during the unique check.

@param  \Illuminate\Database\Eloquent\Model  $model
@param  string|null  $idColumn
@return $this
498600
public function ignoreModel($model, $idColumn = null)
    {
        $this->idColumn = $idColumn ?? $model->getKeyName();
        $this->ignore = $model->{$this->idColumn};

        return $this;
    }
1353995
public function remove(Builder $builder, Model $model)
    {
        $query      = $builder->getQuery();
        $columns    = $model->getQualifiedOrderByColumns();

        foreach ($columns as $column => $direction) {

            foreach ((array) $query->orders as $key => $order) {

                if ($order['column'] == $column) {
                    $this->removeOrderBy($query, $key);
                }
            }
        }
    }
563562
protected function one($model, $column, $value)
    {
        $object = $model::where($column, '=', $value);

        if (!is_null($object)) {
            if (count($object) > 0) {
                return $object[0];
            }
        }
    }
980829
public function remove(Builder $builder, Model $model)
    {
        $query      = $builder->getQuery();
        $column     = $model->getQualifiedPositionColumn();

        foreach ((array) $query->orders as $key => $order) {

            if ($order['column'] == $column) {
                $this->removeOrderBy($query, $key);
            }
        }
    }
947507
public function forgetColumn(AbstractColumn $column): State
    {
        foreach ($this->columns as $name => $columnSchema) {
            if ($columnSchema == $column) {
                unset($this->columns[$name]);
                break;
            }
        }

        return $this;
    }
342015
public function unlink(Model $model) {
        $this->getUnlinked()->flush()->append($model);

        $this->getPrimaryModel()->set($this->getPrimaryForeignKey(), null);

        return $this;
    }
357686
public function remove(Builder $builder, Model $model)
    {
        $query = $builder->getQuery();

        if (is_null($query->wheres)) {
            return;
        }

        $bindingKey = 0;

        $scopeConstraints = $this->getScopeConstraints($model);

        foreach ((array) $query->wheres as $key => $where) {
            $bindingsCount = $this->countBindings($where);

            if (in_array($where, $scopeConstraints)) {
                $this->removeWhere($query, $key);

                $this->removeBindings($query, $bindingKey, $bindingsCount);
            } else {
                $bindingKey += $bindingsCount;
            }
        }

        $query->wheres = array_values($query->wheres);
    }
1280172
public function setModel($model, $ids = [])
    {
        $this->model = $model;
        $this->ids = Arr::wrap($ids);

        $this->message = "No query results for model [{$model}]";

        if (count($this->ids) > 0) {
            $this->message .= ' '.implode(', ', $this->ids);
        } else {
            $this->message .= '.';
        }

        return $this;
    }
1039290
public function persist(ModelInterface $model): RepositoryInterface
    {
        $id = $model->getId();
        $row = $model->toPersistence();

        $this->connection->beginTransaction();

        $alreadyExists = (bool) $this->find($id);

        $stack = new RelatedModelManipulationStack();

        foreach ($row as $field => $value) {
            if ($value instanceof ModelCollectionInterface) {
                $stack->addToRemoveModels($value->getInitialModels());
                $stack->addToPersistModels($value->getModels());
                unset($row[$field]);
            } elseif ($value instanceof ModelReferenceInterface) {
                $row[$field.'Id'] = $this->persistModelReference($value, $stack);

                unset($row[$field]);
            }
        }

        if (!$alreadyExists) {
            $this->insert($id, $row);
        } else {
            $this->update($id, $row);
        }

        $this->removeRelatedModels($stack->getToRemoveModels());
        $this->persistRelatedModels($stack->getToPersistModels());

        $this->storageCache->set($id, $row);

        $this->connection->commit();

        return $this;
    }
929015
protected function saveColumns(Model $model)
    {
        /** @var \T4\Orm\Model $class */
        $class = get_class($model);
        $columns = $class::getColumns();
        $relations = $class::getRelations();
        $cols = [];
        $sets = [];
        $data = [];

        foreach ($columns as $column => $def) {
            if (isset($model->{$column}) && null === $model->{$column} && isset($def['default'])) {
                $sets[$column] = ':' . $column;
                $data[':'.$column] = $def['default'];
            } else {
                $cols[] = $column;
                $sets[$column] = ':' . $column;
                switch ($def['type']) {
                    case 'boolean':
                        $data[':' . $column] = (int)$model->{$column};
                        break;
                    default:
                        $data[':' . $column] = $model->{$column};
                        break;
                }
            }
        }

        foreach ($relations as $rel => $def) {
            switch ($def['type']) {
                case $class::BELONGS_TO:
                    $column = $class::getRelationLinkName($def);
                    if (!in_array($column, $cols)) {
                        // todo: test this!
                        //if (isset($model->{$column}) && !is_null($model->{$column})) {
                        if (isset($model->{$column})) {
                            $sets[$column] = ':' . $column;
                            $data[':'.$column] = $model->{$column};
                        } elseif (isset($model->{$rel}) && $model->{$rel} instanceof Model) {
                            $sets[$column] = ':' . $column;
                            $data[':'.$column] = $model->{$rel}->getPk();
                        }
                    }
                    break;
            }
        }

        $connection = $class::getDbConnection();
        if ($model->isNew()) {
            $query = new Query();
            $query->insert($class::getTableName())
                ->values($sets)
                ->params($data);
            $connection->execute($query);
            $model->{$class::PK} = $connection->lastInsertId();
        } else {
            $query = new Query();
            $query->update($class::getTableName())
                ->values($sets)
                ->where($this->quoteName($class::PK) . '='. $model->getPk())
                ->params($data);
            $connection->execute($query);
        }

        return $model;

    }
1282476
public function link(Model $model) {
        $this->getLinked()->flush()->append($model);

        $this->getPrimaryModel()->set($this->getPrimaryForeignKey(), $model->id());

        return $this;
    }
141834
protected function relationColumn($related, $model, $column = null)
    {
        $table = $related::$table;
        //
        return !is_null($column) ? $column : $this->idKey($table);
    }
451612
public function remove(Builder $builder, Model $model)
    {
        $query = $builder->getQuery();

        foreach ((array)$query->wheres as $key => $where)
        {
            if ($where['column'] === $model->getTypeKeyName())
            {
                unset($query->wheres[$key]);

                $query->wheres = array_values($query->wheres);
            }
        }
    }
55604
public function remove(Builder $builder, Model $model)
    {
        $query      = $builder->getQuery();
        $column     = $model->getQualifiedActiveColumn();
        $bindingKey = 0;

        foreach ((array) $query->wheres as $key => $where) {

            if ($this->isActiveConstraint($where, $column)) {

                $this->removeWhere($query, $key);
                $this->removeBinding($query, $bindingKey);
            }

            if ( ! in_array($where['type'], ['Null', 'NotNull'])) {
                $bindingKey++;
            }
        }
    }
134431
public function setPrimaryModel(Model $model) {
        $this->_model = $model;
        $this->setPrimaryClass(get_class($model));

        return $this;
    }
276568
public function undelete($model, $id) {
		$runtime = $this->runtime[$model->alias];
		$this->softDelete($model, false);

		$data = array();
		$fields = $this->_normalizeFields($model);
		foreach ($fields as $flag => $date) {
			if (true === $runtime || $flag === $runtime) {
				$data[$flag] = false;
				if ($date) {
					$data[$date] = null;
				}
				if ($flag === $runtime) {
					break;
				}
			}
		}

		$model->create();
		$model->set($model->primaryKey, $id);
		$result = $model->save(array($model->alias => $data), false, array_keys($data));
		$this->softDelete($model, $runtime);
		return $result;
	}
1327210
public function setModel(Model $model)
    {
        if (($content = $this->getContent()) instanceof WithModelInterface) {
            $content->setModel($model);
        }

        return $this;
    }