Casts
1 month ago
Concerns
1 month ago
Factories
1 month ago
Relations
1 month ago
BroadcastableModelEventOccurred.php
1 month ago
BroadcastsEvents.php
6 months ago
Builder.php
1 month ago
Collection.php
1 month ago
HigherOrderBuilderProxy.php
2 years ago
InvalidCastException.php
2 years ago
JsonEncodingException.php
2 years ago
MassAssignmentException.php
2 years ago
MassPrunable.php
6 months ago
MissingAttributeException.php
1 month ago
Model.php
1 month ago
ModelNotFoundException.php
1 month ago
PendingHasThroughRelationship.php
1 month ago
Prunable.php
2 years ago
QueueEntityResolver.php
2 years ago
RelationNotFoundException.php
2 years ago
Scope.php
2 years ago
SoftDeletes.php
1 month ago
SoftDeletingScope.php
1 month ago
HigherOrderBuilderProxy.php
49 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWPSCOPED\Illuminate\Database\Eloquent; |
| 4 | |
| 5 | /** |
| 6 | * @mixin \Illuminate\Database\Eloquent\Builder |
| 7 | * @internal |
| 8 | */ |
| 9 | class HigherOrderBuilderProxy |
| 10 | { |
| 11 | /** |
| 12 | * The collection being operated on. |
| 13 | * |
| 14 | * @var \Illuminate\Database\Eloquent\Builder |
| 15 | */ |
| 16 | protected $builder; |
| 17 | /** |
| 18 | * The method being proxied. |
| 19 | * |
| 20 | * @var string |
| 21 | */ |
| 22 | protected $method; |
| 23 | /** |
| 24 | * Create a new proxy instance. |
| 25 | * |
| 26 | * @param \Illuminate\Database\Eloquent\Builder $builder |
| 27 | * @param string $method |
| 28 | * @return void |
| 29 | */ |
| 30 | public function __construct(Builder $builder, $method) |
| 31 | { |
| 32 | $this->method = $method; |
| 33 | $this->builder = $builder; |
| 34 | } |
| 35 | /** |
| 36 | * Proxy a scope call onto the query builder. |
| 37 | * |
| 38 | * @param string $method |
| 39 | * @param array $parameters |
| 40 | * @return mixed |
| 41 | */ |
| 42 | public function __call($method, $parameters) |
| 43 | { |
| 44 | return $this->builder->{$this->method}(function ($value) use($method, $parameters) { |
| 45 | return $value->{$method}(...$parameters); |
| 46 | }); |
| 47 | } |
| 48 | } |
| 49 |