Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/Engines/Invokable.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Kettasoft\Filterable\Engines\Foundation\Clause;
use Kettasoft\Filterable\Engines\Foundation\ClauseFactory;
use Kettasoft\Filterable\Engines\Foundation\Parsers\Dissector;
use Kettasoft\Filterable\Filterable;

class Invokable extends Engine
{
Expand Down Expand Up @@ -56,6 +57,11 @@ public function execute(Builder $builder): Builder

$method = $this->getMethodName($filter);

// Check for method name conflicts with Filterable core methods.
if (method_exists(Filterable::class, $method)) {
throw new \RuntimeException(sprintf("Filter method [%s] conflicts with core Filterable method.", [$method]));
}

$this->initializeFilters($filter, $method, $clause->getPayload());
}

Expand Down Expand Up @@ -110,16 +116,31 @@ protected function getAllowedFieldsFromConfig(): array
return config('filterable.engines.invokable.allowed_fields', []);
}

/**
* Get allowed operators to filtering.
*
* @return array
*/
public function getOperatorsFromConfig(): array
{
return config('filterable.engines.invokable.allowed_operators', []);
}

/**
* Check if filter has strict mode.
*
* @return bool
*/
public function isStrictFromConfig(): bool
{
return config('filterable.engines.invokable.strict', true);
}

/**
* Check if empty values are ignored from config.
*
* @return bool
*/
public function isIgnoredEmptyValuesFromConfig(): bool
{
return config('filterable.engines.invokable.ignore_empty_values', false);
Expand Down