Tailor\Behaviors\VersionController

Overview

VersionController is a modifier to FormController to enable version records

Extends

Public Properties

There are no public properties in the class.

Show inherited public properties

Inherited Public Properties

Protected Properties

protected Model $primaryModel

model used by the form

protected Model $model

model used by the form

protected string $versionId

protected array $modelsToSave

modelsToSave are models that require saving

Show inherited protected properties

Inherited Protected Properties


Public Methods

public getVersionId()

public getVersionId(): string 

public initVersion()

public initVersion($model): void

public isVersionMode()

public isVersionMode(): bool 

public onRestoreVersion()

public onRestoreVersion($recordId = null): void

onRestoreVersion restores a version to the primary model

public update()

public update(int $recordId = null): void 

Controller "update" action used for updating existing model records.

public versionBeforeSave()

public versionBeforeSave($model): void

public versionGetPrimaryModel()

public versionGetPrimaryModel(): void

public versionGetVersionModel()

public versionGetVersionModel(): void

Show inherited public methods

Inherited Public Methods

Protected Methods

protected deferPurgedSaveAttributes()

protected deferPurgedSaveAttributes(
    October\Rain\Database\Model $model,
    array $attributesToPurge
): void 

deferPurgedSaveAttributes removes an array of attributes from the model. If the model implements the Purgeable trait, this is preferred over the internal logic.

protected performSaveOnModel()

protected performSaveOnModel($model, $data, $options = null): void

performSaveOnModel saves complex data against a model inside a database transaction.

protected prepareModelsToSave()

protected prepareModelsToSave(
    October\Rain\Database\Model $model,
    array $saveData
): array 

prepareModelsToSave takes a model and fills it with data from a multidimensional array. If an attribute is found to be a relationship, that relationship is also filled.

$modelsToSave = $this->prepareModelsToSave($model, [...]);

foreach ($modelsToSave as $modelToSave) {
    $modelToSave->save();
}

protected setModelAttributes()

protected setModelAttributes(
    October\Rain\Database\Model $model,
    array $saveData,
    $attrName = ''
): void 

setModelAttributes sets a data collection to a model attributes, relations are also set.

Show inherited protected methods

Inherited Protected Methods