diff --git a/src/ConditionsGeneratorTrait.php b/src/ConditionsGeneratorTrait.php index c95d36b..498933b 100644 --- a/src/ConditionsGeneratorTrait.php +++ b/src/ConditionsGeneratorTrait.php @@ -351,6 +351,7 @@ public function getInputArgs($key = null, $default = null) protected function isVaildInput($requestKey) { return Arr::has($this->inputArgs, $requestKey) + && Arr::get($this->inputArgs, $requestKey) !== [] && Arr::get($this->inputArgs, $requestKey) !== null && Arr::get($this->inputArgs, $requestKey) !== ''; } diff --git a/tests/Unit/ConditionGeneratorTrait/HandlePaginate.php b/tests/Unit/ConditionGeneratorTrait/HandlePaginate.php index 29239de..712c5a7 100644 --- a/tests/Unit/ConditionGeneratorTrait/HandlePaginate.php +++ b/tests/Unit/ConditionGeneratorTrait/HandlePaginate.php @@ -36,4 +36,17 @@ public function test_order() 'id' => 'asc', ], Arr::get($conditions, 'order')); } + + public function test_fireInput() + { + $fakeRequest = new FakeRequest(); + + $conditions = $fakeRequest->getConditions([ + 'empty_array_field' => [] + ]); + + $this->assertEquals([ + 'id' => 'asc', + ], Arr::get($conditions, 'order')); + } } diff --git a/tests/Utils/FakeRequest.php b/tests/Utils/FakeRequest.php index 604b5c6..b71aa0b 100644 --- a/tests/Utils/FakeRequest.php +++ b/tests/Utils/FakeRequest.php @@ -8,6 +8,15 @@ class FakeRequest { use ConditionsGeneratorTrait; + protected function wheres() + { + return [ + 'empty_array_field' => $this->fireInput('empty_array_field', function($value) { + return $value.'%'; + }), + ]; + } + protected function order() { return '+id';