HipsterJazzbo\Landlord\TenantManager::newQueryWithoutTenants PHP Method

newQueryWithoutTenants() public method

Get a new Eloquent Builder instance without any of the tenant scopes applied.
public newQueryWithoutTenants ( Model $model ) : Builder
$model Illuminate\Database\Eloquent\Model
return Illuminate\Database\Eloquent\Builder
    public function newQueryWithoutTenants(Model $model)
    {
        return $model->newQuery()->withoutGlobalScopes($this->tenants->keys()->toArray());
    }

Usage Example

 /**
  * Returns a new query builder without any of the tenant scopes applied.
  *
  *     $allUsers = User::allTenants()->get();
  *
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public static function allTenants()
 {
     return static::$landlord->newQueryWithoutTenants(new static());
 }