src/Schema/CreatesEloquentIdentities.php
protected function createModelIdentity(
        $modelClass,
        $id,
        $keyName = null
    ) {
        if (is_null($id)) {
            return null;
        }

        $model = new $modelClass();

        if (!$model instanceof Model) {
            throw new RuntimeException(sprintf('Expecting a model class, got %s.', $modelClass));
        }

        $model->setAttribute($keyName ?: $model->getRouteKeyName(), $id);

        return $model;
    }
protected function createModelIdentity(
        $modelClass,
        $id,
        $keyName = null
    ) {
        if (is_null($id)) {
            return null;
        }

        $model = new $modelClass();

        if (!$model instanceof Model) {
            throw new RuntimeException(sprintf('Expecting a model class, got %s.', $modelClass));
        }

        $model->setAttribute($keyName ?: $model->getRouteKeyName(), $id);

        return $model;
    }
Create a model identity using the model class and a provided id.

@param $modelClass
@param string|int|null $id
@param string|null $keyName
the key to set as the id - defaults to `Model::getRouteKeyName()`
@return Model|null
@deprecated