mehdi-fathi/eloquent-filter

f_params[limit]=XXX not working as expected

gregoirer opened this issue · 1 comments

Hello,

When we use f_params[limit]=\d it gives one result only whatever the limit we provide (it act like we have queried f_params[limit]=1) .

Suggested fix below:

public function apply($query): Builder
{
foreach ($this->values as $key => $param) {
if (!in_array($key, self::$reserve_param['f_params'])) {
throw new \Exception("$key is not in f_params array.");
}
if (is_array($param)) {
$this->values['orderBy']['field'] = explode(',', $this->values['orderBy']['field']);
foreach ($this->values['orderBy']['field'] as $order_by) {
$query->orderBy($order_by, $this->values['orderBy']['type']);
}
} else {
$query->limit($param);
}
}

    return $query;
}

@gregoirer Thanks for this report. This bug will fix in the next version.