October\Rain\Database\Traits\Multisite

Overview

Multisite trait allows for site-based models, the database table should contain site_id and site_root_id keys


Public Methods

public addPropagatable()

public addPropagatable(array|string|null $attributes = null): void

addPropagatable attributes for the model.

public static bootMultisite()

public static bootMultisite(): void

bootMultisite trait for a model.

public canDeleteMultisiteRelation()

public canDeleteMultisiteRelation($name, $type = null): bool 

canDeleteMultisiteRelation checks if a relation has the potential to be shared with the current model. If there are 2 or more records in existence, then this method will prevent the cascading deletion of relations.

See Also

public deleteForSite()

public deleteForSite($siteId = null): void

deleteForSite runs the delete command on a model for another site, useful for cleaning up records for other sites when the parent is deleted.

public findForSite()

public findForSite($siteId = null): void

findForSite will locate a record for a specific site.

public findOrCreateForSite()

public findOrCreateForSite($siteId = null): void

public getMultisiteConfig()

public getMultisiteConfig($key, $default = null): void

public getMultisiteSyncSites()

public getMultisiteSyncSites(): array 

public getQualifiedSiteIdColumn()

public getQualifiedSiteIdColumn(): string 

getQualifiedSiteIdColumn gets the fully qualified "site id" column.

public getSiteIdColumn()

public getSiteIdColumn(): string 

getSiteIdColumn gets the name of the "site id" column.

public initializeMultisite()

public initializeMultisite(): void

public isAttributePropagatable()

public isAttributePropagatable($attribute): bool 

public isMultisiteEnabled()

public isMultisiteEnabled(): bool 

isMultisiteEnabled allows for programmatic toggling

public isMultisiteSyncEnabled()

public isMultisiteSyncEnabled(): void

public multisiteAfterCreate()

public multisiteAfterCreate(): void

multisiteAfterCreate constructor event used internally

public multisiteAfterDelete()

public multisiteAfterDelete(): void

public multisiteBeforeSave()

public multisiteBeforeSave(): void

multisiteBeforeSave constructor event used internally

public multisiteSaveComplete()

public multisiteSaveComplete(): void

multisiteSaveComplete constructor event used internally

public newOtherSiteQuery()

public newOtherSiteQuery(): void

public propagateToSite()

public propagateToSite($siteId, $otherModel = null): void

propagateToSite will save propagated fields to other records

public savePropagate()

public savePropagate($options = null, $sessionKey = null): bool 

savePropagate the model, including to other sites

public scopeApplyOtherSiteRoot()

public scopeApplyOtherSiteRoot(
    Illuminate\Database\Eloquent\Builder $query,
    string|\Illuminate\Database\Eloquent\Model $idOrModel
): Illuminate\Database\Eloquent\Builder 

scopeApplyOtherSiteRoot is used to resolve a model using its ID or its root ID. For example, finding a model using attributes from another site, or finding all connected models for all sites.

Protected Methods

protected defineMultisiteRelation()

protected defineMultisiteRelation($name, $type = null): void

defineMultisiteRelation will modify defined relations on this model so they share their association using the shared identifier (site_root_id). Only these relation types support relation sharing: belongsToMany, belongsTo, hasOne, hasMany, attachOne, attachMany.

protected defineMultisiteRelations()

protected defineMultisiteRelations(): void

defineMultisiteRelations will spin over every relation and apply propagation config

protected findOtherSiteModel()

protected findOtherSiteModel($siteId = null): void

protected isModelUsingSameSite()

protected isModelUsingSameSite($siteId = null): void