Skip to content

Commit

Permalink
refact forward call to be able to call same method name
Browse files Browse the repository at this point in the history
  • Loading branch information
wheesnoza committed Oct 2, 2020
1 parent ae29655 commit 716cfbd
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/ModelSearchAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public function getResults(string $term): Collection

$query = ($this->model)::query();

foreach ($this->callsToForward as $method => $parameters) {
$this->forwardCallTo($query, $method, $parameters);
foreach ($this->callsToForward as $callToForward) {
$this->forwardCallTo($query, $callToForward['method'], $callToForward['parameters']);
}

$this->addSearchConditions($query, $term);
Expand Down Expand Up @@ -130,7 +130,10 @@ protected function addSearchConditions(Builder $query, string $term)

public function __call($method, $parameters)
{
$this->callsToForward[$method] = $parameters;
$this->callsToForward[] = [
'method' => $method,
'parameters'=> $parameters,
];

return $this;
}
Expand Down

0 comments on commit 716cfbd

Please sign in to comment.