1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace Illuminate\Database\Eloquent;
- /**
- * @mixin \Illuminate\Database\Eloquent\Builder
- */
- class HigherOrderBuilderProxy
- {
- /**
- * The collection being operated on.
- *
- * @var \Illuminate\Database\Eloquent\Builder
- */
- protected $builder;
- /**
- * The method being proxied.
- *
- * @var string
- */
- protected $method;
- /**
- * Create a new proxy instance.
- *
- * @param Builder $builder
- * @param string $method
- */
- public function __construct(Builder $builder, $method)
- {
- $this->method = $method;
- $this->builder = $builder;
- }
- /**
- * Proxy a scope call onto the query builder.
- *
- * @param string $method
- * @param array $parameters
- * @return mixed
- */
- public function __call($method, $parameters)
- {
- return $this->builder->{$this->method}(function ($value) use ($method, $parameters) {
- return $value->{$method}(...$parameters);
- });
- }
- }
|