Skip to content

Commit

Permalink
Fix where value is 0 or '0' bug
Browse files Browse the repository at this point in the history
  • Loading branch information
zhichao-poper committed Dec 12, 2019
1 parent 926893e commit 8c3c97c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/ConditionsGeneratorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,10 @@ public function getConditions($args)

// 遍历 where 配置,生成 getList 所需要的 where 结构
$this->conditions['wheres'] = collect($this->conditions['wheres'])
->filter()
->mapWithKeys(function ($item, $key) use ($args) {
->filter(function($item) {
return $item !== null;
})
->mapWithKeys(function ($item, $key) {
return $this->generateWhereKeyValue($item, $key);
})->all();

Expand Down
4 changes: 3 additions & 1 deletion src/Lighthouse/Directives/GetlistDirective.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ function ($root, array $args) use ($value) {
$args = collect([
'paginator.sort' => $this->directiveArgValue('sort'),
'paginator.sorts' => $this->directiveArgValue('sorts'),
])->merge($args)->filter()->toArray();
])->merge($args)->filter(function($item) {
return $item !== null;
})->toArray();

$model = $this->getPaginatorModel();

Expand Down

0 comments on commit 8c3c97c

Please sign in to comment.