mehdi-fathi / eloquent-filter

Eloquent Filter is a package for filter data of models by the query strings. Easy to use and fully dynamic.
https://mehdi-fathi.github.io/eloquent-filter/
MIT License
436 stars 42 forks source link

f_params[limit]=XXX not working as expected #162

Closed gregoirer closed 3 years ago

gregoirer commented 3 years ago

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;
}
mehdi-fathi commented 3 years ago

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