diff --git a/src/Builder.php b/src/Builder.php index d8365fd5..c25ed9b9 100644 --- a/src/Builder.php +++ b/src/Builder.php @@ -5,13 +5,15 @@ use Illuminate\Container\Container; use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\Paginator; +use Illuminate\Support\Traits\Conditionable; use Illuminate\Support\Traits\Macroable; +use Illuminate\Support\Traits\Tappable; use Laravel\Scout\Contracts\PaginatesEloquentModels; use Laravel\Scout\Contracts\PaginatesEloquentModelsUsingDatabase; class Builder { - use Macroable; + use Conditionable, Macroable, Tappable; /** * The model instance. @@ -262,36 +264,6 @@ public function options(array $options) return $this; } - /** - * Apply the callback's query changes if the given "value" is true. - * - * @param mixed $value - * @param callable $callback - * @param callable $default - * @return mixed - */ - public function when($value, $callback, $default = null) - { - if ($value) { - return $callback($this, $value) ?: $this; - } elseif ($default) { - return $default($this, $value) ?: $this; - } - - return $this; - } - - /** - * Pass the query to a given callback. - * - * @param \Closure $callback - * @return $this - */ - public function tap($callback) - { - return $this->when(true, $callback); - } - /** * Set the callback that should have an opportunity to modify the database query. *