Gets the next auto-increment id for a model

@param Model $model
@return int
@throws \Exception
356042
public static function getNextId(Model $model)
    {
        $statement = DB::select('show table status like \''.$model->getTable().'\'');

        if (!isset($statement[0]) || !isset($statement[0]->Auto_increment)) {
            throw new \Exception('Unable to retrieve next auto-increment id for this model.');
        }

        return (int) $statement[0]->Auto_increment;
    }
533774
public function getIdMetaMapByType( $model, $type ) {

		$modelMetaService = Yii::$app->factory->get( 'modelMetaService' );

		return $modelMetaService->getIdMetaMapByType( $model->id, static::$parentType, $type );
	}
1325266
protected function makeGenericUpdate(Model $model)
	{
		// Get first fillable key that is not the models primary key.
		$field = array_first(
			$model->getFillable(), function ($key, $value) use ($model) {
			return ($value !== $model->getKeyName());
		}
		);

		switch (gettype($model->{$field})) {
			case 'string':
				$model->{$field} = $model->{$field} . ' updated';
				break;
			case 'boolean':
				$model->{$field} = ! $model->{$field};
				break;
			case 'integer':
			case 'NULL':
			default:
				$model->{$field} = $model->{$field} + 1;
		}

		return $this;
	}
999510
public function getControllerName(Model $model) {
		$modelNamePlural = $this->getModelNamePlural($model, false);
		$controllerName = mb_strtolower(Inflector::underscore($modelNamePlural));

		return $controllerName;
	}
13110
protected function getModel($model)
    {
        if ($model instanceof Model) {
            return $model;
        }

        if (!class_exists($model) || !is_string($model) || !is_subclass_of($model, Model::class)) {
            throw new \InvalidArgumentException("Invalid model [$model] !");
        }

        return new $model();
    }
187346
protected function getForeignKeyName(Model $model)
    {
        $table = $model->getTable();

        if (array_key_exists($table, $this->foreignKeyLookup)) {
            return $this->foreignKeyLookup[$table];
        }

        return Str::singular($table).'_id';
    }
515695
public function getDeleteUrl($model = null)
    {
        if (!$model instanceof Mage_Core_Model_Abstract) {
            $model = $this->getCurrentRecord();
        } else {
            $expectedClass = get_class($this->getModel());
            if (!is_a($model, $expectedClass)) {
                throw new RuntimeException($this->__('Invalid model class. Expected:%1$s Passed:%2$s', $expectedClass, get_class($model)));
            }
        }

        return $this->_getUrl($this->getDeleteRoute(), [$model->getIdFieldName() => $model->getId()]);
    }
1018992
public function getName(Model $model, $id = null) {
		if (empty($id) || empty($model->displayField)) {
			return false;
		}
		if (is_array($id)) {
			if (!isset($id[$model->alias][$model->displayField])) {
				return false;
			}

			$result = $id[$model->alias][$model->displayField];
		} else {
			$model->id = $id;
			$result = $model->field($model->displayField);
		}

		return $result;
	}
959569
protected function getReferenceFallback(Model $model)
    {
        // Use reference method if the model has one
        if (method_exists($model, 'getReferenceAttribute')) {
            return $model->reference;
        }

        if (method_exists($model, 'getReference')) {
            return $model->getReference();
        }

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

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

        return $this;
    }
649903
public function get_next_id()
    {
        return (int) $this->_database->select('AUTO_INCREMENT')
            ->from('information_schema.TABLES')
            ->where('TABLE_NAME', $this->_table)
            ->where('TABLE_SCHEMA', $this->_database->database)->get()->row()->AUTO_INCREMENT;
    }
150410
protected function setModelForElements(Model $model)
    {
        $this->getElements()->each(function ($element) use ($model) {
            $element = $this->getElementContainer($element);

            if ($element instanceof WithModelInterface) {
                $element->setModel($model);
            }
        });

        return $this;
    }
232641
public function getLikedRecord(Model $model): ?Model
    {
        return $this->likes()
                    ->where('liked_by_id', $model->id)
                    ->where('liked_by_type', get_class($model))
                    ->first();
    }
439569
public function setHabtmData(Model $model) {
        foreach ($model->hasAndBelongsToMany as $assoc) {
            if (!$assoc['showInForm']) {
                continue;
            }

            $object = Admin::introspectModel($assoc['className']);
            $variable = Inflector::variable(Inflector::pluralize(preg_replace('/(?:_id)$/', '', $assoc['associationForeignKey'])));

            $this->Controller->set($variable, $this->getRecordList($object));
        }
    }
247548
public function delete(Model $model)
    {
        $deleted = $model->delete();

        if ($deleted) {
            app('cache')->flush();
        }

        return $deleted;
    }
614549
protected function getModuleByModel(Model $model)
    {
        /** @var ModuleManagerInterface $modules */
        $modules = app(ModuleManagerInterface::class);

        return $modules->getByAssociatedClass(get_class($model));
    }
923756
public function nextId($table)
    {
        $this->sql = "SHOW TABLE STATUS LIKE '{$this->tablePre}$table'";
        $stmt = $this->execute();
        return $stmt->fetchObject()->Auto_increment;
    }