Determine if two models have the same ID and belong to the same table.

@param  \Illuminate\Database\Eloquent\Model|null  $model
@return bool
2330
public function is($model)
    {
        return ! is_null($model) &&
               $this->getKey() === $model->getKey() &&
               $this->getTable() === $model->getTable() &&
               $this->getConnectionName() === $model->getConnectionName();
    }
712369
public function isPendingOrSaved($model)
    {
        return $this->store->isSaved($model) || $this->store->isPending($model);
    }
143206
public function is(Model $model)
    {
        return $this->getKey() === $model->getKey() &&
               $this->getTable() === $model->getTable() &&
               $this->getConnectionName() === $model->getConnectionName();
    }
409185
public function save(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 {
            $model->setAttribute($foreignKey, $parentKeyValue);
        }

        return $model->save() ? $model : false;
    }
1005007
protected function has_one( $model, $foreign_key = null, $local_key = null )
	{
		return new Model_Relation_HasOne( $this, $model, $foreign_key, $local_key );
	}
627720
public function deleteModel($model)
    {
        // first remove any automatically created models
        /** @var $relationField ManyToManyField */
        foreach ($model->getMeta()->localManyToMany as $name => $relationField) {
            if ($relationField->relation->through->getMeta()->autoCreated) {
                $this->deleteModel($relationField->relation->through);
            }
        }
        $this->dropTable($model->getMeta()->getDbTable());
    }
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;
    }
1093031
protected function determineStrategy(Model $model, $column)
    {
        if ($this->isColumnTranslated($model, $column)) {
            return $this->getStrategyForTranslated();
        }

        if ($this->isColumnOnRelatedModel($model, $column)) {
            return $this->getStrategyForRelatedModelAttribute();
        }

        if ($this->isColumnOnModelTable($model, $column)) {
            return $this->getStrategyForDirectAttribute();
        }

        return false;
    }
1278204
public function getModel($model = null)
    {
        $model          = $model ?? $this->model ?? $this->serviceAlias;
        $sl             = $this->getServiceLocator();
        $modelManager   = $sl->get(ModelManager::class);
        $model          = $modelManager->get($model);

        return $model;
    }
1016022
private function getId($model)
    {
        // Check to see if we can get an id via our defined methods
        foreach (self::$methods as $method) {
            if (method_exists($model, $method) && is_callable([$model, $method])) {
                return $model->$method();
            }
        }

        // Check to see if we can get an id via our defined properties
        foreach (self::$properties as $property) {
            if (isset($model->$property)) {
                return $model->$property;
            }
        }
    }
66414
public function info($model = null)
    {
        $debug = $this->isDebug();
        $this->setDebug(false);

        if (is_null($model)) {
            $this->info($this->getModels());
        } elseif (is_array($model) && count($model) > 0) {
            foreach ($model as $m) {
                $this->info($m);
            }
        } elseif (is_array($model) && count($model) == 0) {
            echo '<pre><table border="1">'
               .'<tr><th>No database tables</th></tr></table></pre>'
               .'</table></pre>';
        } else {
            $desc = $this->desc($model);
            Functions::dumpSchema($desc);
        }

        $this->setDebug($debug);
    }
255472
public function equals( $reference ) {
        if ( !( $reference instanceof EntityReference ) ) {
            return false;
        }

        if ( strcasecmp( $this->entityLogicalName, $reference->entityLogicalName ) !== 0 ) {
            return false;
        }

        if ( $this->getID() !== $reference->getID() ) {
            return false;
        }

        return true;
    }
225514
public function isDevice($model)
    {
        return (!empty($this->device->series) && $this->device->series == $model) || (!empty($this->device->model) && $this->device->model == $model);
    }
87833
public function creating(Model $model)
    {
        $model->created_at = time();
        $model->created_by = $this->guard->check() ? $this->guard->user()->getId() : null;
    }
946959
public function undo(Model $Model) {
		if (!$Model->id) {
			trigger_error('RevisionBehavior: Model::id must be set', E_USER_WARNING);
			return null;
		}
		if (!$Model->ShadowModel) {
			trigger_error('RevisionBehavior: ShadowModel doesnt exist.', E_USER_WARNING);
			return false;
		}
		$data = $this->previous($Model);
		if (!$data) {
			$Model->logableAction['Revision'] = 'undo add';
			$Model->delete($Model->id);
			return false;
		}
		foreach ($Model->getAssociated('hasAndBelongsToMany') as $assocAlias) {
			if (isset($Model->ShadowModel->_schema[$assocAlias])) {
				$data[$assocAlias][$assocAlias] = explode(',', $data[$Model->alias][$assocAlias]);
			}
		}
		$Model->logableAction['Revision'] = 'undo changes';
		return (bool)$Model->save($data);
	}
535650
public function save(Model $model)
    {
        $model->setAttribute($this->getPlainForeignKey(), $this->getParentKey());

        return $model->save() ? $model : false;
    }
145954
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->relation, $model);
        }

        return $this->child;
    }