Applies applicable tenant scopes to a model.
public applyTenantScopes ( |
||
$model |
/** * Boot the trait. Will apply any scopes currently set, and * register a listener for when new models are created. */ public static function bootBelongsToTenants() { // Grab our singleton from the container static::$landlord = app(TenantManager::class); // Add a global scope for each tenant this model should be scoped by. static::$landlord->applyTenantScopes(new static()); // Add tenantColumns automatically when creating models static::creating(function (Model $model) { static::$landlord->newModel($model); }); }