-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement custom filters and refactor core components
This commit introduces custom filtering capabilities and includes several improvements: - Add support for custom filters in the Filterable trait - Create MakeCustomFilterCommand for generating custom filter classes - Refactor FiltersBuilder for better performance and maintainability - Move FiltererServiceProvider to Providers namespace - Enhance error handling and type checks throughout the package - Update README with custom filter documentation and examples - Add tests for new custom filter functionality
- Loading branch information
Showing
13 changed files
with
421 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace CultureGr\Filterer\Commands; | ||
|
||
use Illuminate\Console\GeneratorCommand; | ||
|
||
class MakeCustomFilterCommand extends GeneratorCommand { | ||
/** | ||
* The console command name. | ||
* | ||
* @var string | ||
*/ | ||
protected $name = 'make:custom-filter'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Create a new custom filter class'; | ||
|
||
/** | ||
* The type of class being generated. | ||
* | ||
* @var string | ||
*/ | ||
protected $type = 'CustomFilter'; | ||
|
||
/** | ||
* Get the stub file for the generator. | ||
* | ||
* @return string | ||
*/ | ||
protected function getStub() | ||
{ | ||
return dirname(__DIR__) . '/stubs/custom-filter.stub'; | ||
} | ||
|
||
/** | ||
* Get the default namespace for the class. | ||
* | ||
* @param string $rootNamespace | ||
* @return string | ||
*/ | ||
protected function getDefaultNamespace($rootNamespace) | ||
{ | ||
return $rootNamespace.'\CustomFilters'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace CultureGr\Filterer\Contracts; | ||
|
||
use Illuminate\Database\Eloquent\Builder; | ||
|
||
interface CustomFilter | ||
{ | ||
/** | ||
* Apply the custom filter to the query builder. | ||
* | ||
* @param Builder $builder The query builder instance | ||
* @param array<string, mixed> $filter The filter array | ||
* | ||
* @phpstan-param array{ | ||
* column: string, | ||
* operator: string, | ||
* query_1: string, | ||
* query_2: string | ||
* } $filter | ||
*/ | ||
public function apply(Builder $builder, array $filter): void; | ||
} |
Oops, something went wrong.