Hi I have a eloquent query and I am using query scope. I have a km column in my table and I am passing kmFrom and KmTo values as post data. Now I am doing a eloquent whereBetween and its returning wrong results when I search for km.
For example if I pass kmFrom = 1000 and kmTo = 2000. Its giving me results which are not in between these two values.
Eloquent -:
```
Product::categoriesCategoryId($categoryId)
->km($kmFrom, $kmTo)->get();
```
Query Scope for the km -:
```
public function scopeKm($query, $kmFrom, $kmTo)
{
if(($kmFrom) && ($kmTo)){
return $query->whereBetween('km', ["$kmFrom", "$kmTo"]);
}
return $query;
}
``` Please assist what wrong I am doing.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2xQI2Zz
via IFTTT
Aucun commentaire:
Enregistrer un commentaire