hasGlobalScope() public static method

Determine if a model has a global scope.
public static hasGlobalScope ( Illuminate\Database\Eloquent\Scope | string $scope ) : boolean
$scope Illuminate\Database\Eloquent\Scope | string
return boolean
 /**
  * Sets the tenant id automatically when creating models
  *
  * @param Model|ScopedByTenant $model
  */
 public function creating(Model $model)
 {
     // If the model has had the global scope removed, bail
     if (!$model->hasGlobalScope(new TenantScope())) {
         return;
     }
     // If there is no tenant set, bail
     if (is_null(TenantScope::getTenantId())) {
         return;
     }
     // Otherwise, scope the new model
     $model->{$model->getTenantColumn()} = TenantScope::getTenantId();
 }
 /**
  * Sets the tenant id automatically when creating models
  *
  * @param Model|ScopedByTenant $model
  */
 public function creating(Model $model)
 {
     // If global scope removed from model, silently return
     if (!$model->hasGlobalScope(new TenantScope())) {
         return;
     }
     // If there is no Tenant set, silently return
     if (is_null(TenantScope::getTenantId())) {
         return;
     }
     // Otherwise, scope the new model
     $model->{$model->getTenantColumn()} = TenantScope::getTenantId();
 }
 public function creating(Model $model)
 {
     // If the model has had the global scope removed, bail
     if (!$model->hasGlobalScope($this)) {
         return;
     }
     // Otherwise, scope the new model
     foreach ($this->getModelTenants($model) as $tenantColumn => $tenantId) {
         $model->{$tenantColumn} = $tenantId;
     }
 }
示例#4
0
 /**
  * @param Model $model
  */
 public function creating(Model $model)
 {
     if (!$model->hasGlobalScope($this)) {
         return;
     }
     foreach ($this->getModelTenants($model) as $tenantColumn => $tenantId) {
         $model->{$tenantColumn} = $tenantId;
     }
 }