Ensure that empty values do not add to or from conditions

This commit is contained in:
Oliver Davies 2018-06-01 19:31:24 +01:00
parent 634fc87897
commit 9f1d80f968
2 changed files with 31 additions and 6 deletions

View file

@ -48,9 +48,11 @@ class Filter
*/
public function from($values)
{
$this->properties['from'] = collect($values)->map(function ($value) {
return trim($value);
})->all();
if (!empty($values)) {
$this->properties['from'] = collect($values)->map(function ($value) {
return trim($value);
})->all();
}
return $this;
}
@ -62,9 +64,11 @@ class Filter
*/
public function to($values)
{
$this->properties['to'] = collect($values)->map(function ($value) {
return trim($value);
})->all();
if (!empty($values)) {
$this->properties['to'] = collect($values)->map(function ($value) {
return trim($value);
})->all();
}
return $this;
}