Skip to content

Commit

Permalink
- 优化 condition 查询作用域
Browse files Browse the repository at this point in the history
  • Loading branch information
slowlyo committed Nov 7, 2023
1 parent da59be9 commit 2d3c767
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Traits/ConditionBuilderScopeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
*/
trait ConditionBuilderScopeTrait
{
public function scopeWithConditionBuilder($query)
protected bool $conditionBuilderHideTable = false;

public function scopeWithConditionBuilder($query, $hideTable = false)
{
$filter = request('filter_condition_builder');

$this->conditionBuilderHideTable = $hideTable;

if (blank($filter)) {
return $query;
}
Expand All @@ -36,7 +40,7 @@ protected function buildConditionBuilderQuery($query, $filter)
{
$or = $filter['conjunction'];

if (method_exists($this, 'qualifyColumn')) {
if (method_exists($this, 'qualifyColumn') && !$this->conditionBuilderHideTable) {
$qualifyColumn = fn($field) => $this->qualifyColumn($field);
} else {
$qualifyColumn = fn($field) => $field;
Expand Down

0 comments on commit 2d3c767

Please sign in to comment.