Skip to content

Commit

Permalink
Update:refactor the core code
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdi-fathi committed Aug 14, 2024
1 parent 2db2cb5 commit 233fcb2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/QueryFilter/Core/FilterBuilder/MainQueryFilterBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function apply($builder, array $request = null, array $ignore_request = n
/**
* @return string
*/
public function getNameDriver(): string
public function getNameBuilder(): string
{
$MainBuilderConditions = $this->queryFilterCore->getMainBuilderConditions();

Expand All @@ -88,7 +88,7 @@ private function checkEnableEloquentFilter(): bool
*/
private function buildQuery($builder, ?array $ignore_request, ?array $accept_request, ?array $detections_injected, ?array $black_list_detections): mixed
{
if ($this->getNameDriver() == DBBuilderQueryByCondition::NAME) {
if ($this->isDbBuilder()) {

return $this->buildDbQuery($builder, $ignore_request, $accept_request, $detections_injected, $black_list_detections);
}
Expand Down Expand Up @@ -148,4 +148,12 @@ private function buildEloquentQuery($builder, ?array $ignore_request, ?array $ac
);
}

/**
* @return bool
*/
private function isDbBuilder(): bool
{
return $this->getNameBuilder() == DBBuilderQueryByCondition::NAME;
}

}
5 changes: 4 additions & 1 deletion src/QueryFilter/Core/ResolverDetections.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ private function resolve($filterName, $values, $model)
*/
private function getFiltersDetection(): array
{
if (app('eloquentFilter')->getNameDriver() != DBBuilderQueryByCondition::NAME) {
/** @var MainQueryFilterBuilder $eloquentFilter */
$eloquentFilter = app('eloquentFilter');

if ($eloquentFilter->getNameBuilder() != DBBuilderQueryByCondition::NAME) {
$model = $this->builder->getModel();
} else {
$model = $this->builder->from;
Expand Down

0 comments on commit 233fcb2

Please sign in to comment.