本文整理汇总了PHP中Illuminate\Database\Eloquent\Builder::withoutGlobalScope方法的典型用法代码示例。如果您正苦于以下问题:PHP Builder::withoutGlobalScope方法的具体用法?PHP Builder::withoutGlobalScope怎么用?PHP Builder::withoutGlobalScope使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Builder
的用法示例。
在下文中一共展示了Builder::withoutGlobalScope方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addOnlyOldVersions
/**
* @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;
});
}
示例2: addOnlyOffline
/**
* 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;
});
}
示例3: withoutGlobalScope
/**
* 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);
}
示例4: extend
/**
* 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;
});
}
示例5: addWithoutTranslation
/**
* 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);
});
}
示例6: scopeAllTeams
/**
* @param Builder $query
* @return mixed
*/
public function scopeAllTeams(Builder $query)
{
return $query->withoutGlobalScope('team');
}