withoutGlobalScope() public method

Remove a registered global scope.
public withoutGlobalScope ( Illuminate\Database\Eloquent\Scope | string $scope )
$scope Illuminate\Database\Eloquent\Scope | string
 /**
  * @param Builder $builder
  */
 protected function addOnlyOldVersions(Builder $builder)
 {
     $builder->macro('onlyOldVersions', function (Builder $builder) {
         $model = $builder->getModel();
         $builder->withoutGlobalScope($this)->where($model->getQualifiedIsCurrentVersionColumn(), 0);
         return $builder;
     });
 }
 /**
  * Add the only-trashed extension to the builder.
  *
  * @param  \Illuminate\Database\Eloquent\Builder $builder
  * @return void
  */
 protected function addOnlyOffline(Builder $builder)
 {
     $builder->macro('onlyOffline', function (Builder $builder) {
         $model = $builder->getModel();
         $builder->withoutGlobalScope($this)->where($model->getQualifiedStatusColumn(), '=', false);
         return $builder;
     });
 }
 /**
  * Remove a registered global scope.
  *
  * @param \Illuminate\Database\Eloquent\Scope|string $scope
  * @return $this 
  * @static 
  */
 public static function withoutGlobalScope($scope)
 {
     return \Illuminate\Database\Eloquent\Builder::withoutGlobalScope($scope);
 }
 /**
  * Extend the builder.
  * @param Builder $builder
  */
 public function extend(EloquentBuilder $builder)
 {
     $builder->macro('onlyTranslated', function (EloquentBuilder $builder, $locale = null) {
         $builder->getModel()->setOnlyTranslated(true);
         if ($locale) {
             $builder->getModel()->setLocale($locale);
         }
         return $builder;
     });
     $builder->macro('withUntranslated', function (EloquentBuilder $builder) {
         $builder->getModel()->setOnlyTranslated(false);
         return $builder;
     });
     $builder->macro('withFallback', function (EloquentBuilder $builder, $fallbackLocale = null) {
         $builder->getModel()->setWithFallback(true);
         if ($fallbackLocale) {
             $builder->getModel()->setFallbackLocale($fallbackLocale);
         }
         return $builder;
     });
     $builder->macro('withoutFallback', function (EloquentBuilder $builder) {
         $builder->getModel()->setWithFallback(false);
         return $builder;
     });
     $builder->macro('translateInto', function (EloquentBuilder $builder, $locale) {
         if ($locale) {
             $builder->getModel()->setLocale($locale);
         }
         return $builder;
     });
     $builder->macro('withoutTranslations', function (EloquentBuilder $builder) {
         $builder->withoutGlobalScope(static::class);
         return $builder;
     });
     $builder->macro('withAllTranslations', function (EloquentBuilder $builder) {
         $builder->withoutGlobalScope(static::class)->with('translations');
         return $builder;
     });
 }
 /**
  * Add the with-trashed extension to the builder.
  *
  * @param  \Illuminate\Database\Eloquent\Builder $builder
  * @return void
  */
 protected function addWithoutTranslation(Builder $builder)
 {
     $builder->macro('withoutTranslation', function (Builder $builder) {
         return $builder->withoutGlobalScope($this);
     });
 }
Beispiel #6
0
 /**
  * @param Builder $query
  * @return mixed
  */
 public function scopeAllTeams(Builder $query)
 {
     return $query->withoutGlobalScope('team');
 }