PHP Trait Mpociot\Versionable\VersionableTrait

Datei anzeigen Open project: mpociot/versionable

Protected Properties

Property Type Description
$versioningEnabled boolean Flag that determines if the model allows versioning at all

Public Methods

Method Description
bootVersionableTrait ( ) Initialize model events
currentVersion ( ) : Version Returns the latest version available
disableVersioning ( )
enableVersioning ( )
getVersionModel ( $version_id ) Get a model based on the version id
previousVersion ( ) : Version Returns the previous version
setReasonAttribute ( string $value ) Attribute mutator for "reason" Prevent "reason" to become a database attribute of model
versions ( ) : Illuminate\Database\Eloquent\Relations\MorphMany Return all versions of the model

Protected Methods

Method Description
getAuthUserId ( ) : integer | null
versionablePostSave ( ) : void Save a new version.
versionablePreSave ( ) : void Pre save hook to determine if versioning is enabled and if we're updating the model

Private Methods

Method Description
isValidForVersioning ( ) : boolean Determine if a new version should be created for this model.

Method Details

bootVersionableTrait() public static method

Initialize model events
public static bootVersionableTrait ( )

currentVersion() public method

Returns the latest version available
public currentVersion ( ) : Version
return Version

disableVersioning() public method

public disableVersioning ( )

enableVersioning() public method

public enableVersioning ( )

getAuthUserId() protected method

protected getAuthUserId ( ) : integer | null
return integer | null

getVersionModel() public method

Get a model based on the version id
public getVersionModel ( $version_id )
$version_id

previousVersion() public method

Returns the previous version
public previousVersion ( ) : Version
return Version

setReasonAttribute() public method

Attribute mutator for "reason" Prevent "reason" to become a database attribute of model
public setReasonAttribute ( string $value )
$value string

versionablePostSave() protected method

Save a new version.
protected versionablePostSave ( ) : void
return void

versionablePreSave() protected method

Pre save hook to determine if versioning is enabled and if we're updating the model
protected versionablePreSave ( ) : void
return void

versions() public method

Return all versions of the model
public versions ( ) : Illuminate\Database\Eloquent\Relations\MorphMany
return Illuminate\Database\Eloquent\Relations\MorphMany

Property Details

$versioningEnabled protected_oe property

Flag that determines if the model allows versioning at all
protected bool $versioningEnabled
return boolean