mirror of https://github.com/kcal-app/kcal.git
Maintain other scopes when using the custom "search" filter
This commit is contained in:
parent
a14b58483a
commit
7530bd61bd
|
|
@ -43,14 +43,12 @@ class FoodAdapter extends AbstractAdapter
|
||||||
*/
|
*/
|
||||||
protected function filter($query, Collection $filters)
|
protected function filter($query, Collection $filters)
|
||||||
{
|
{
|
||||||
|
$this->filterWithScopes($query, $filters->except('search'));
|
||||||
if ($term = $filters->get('search')) {
|
if ($term = $filters->get('search')) {
|
||||||
$query->where('foods.name', 'like', "%{$term}%")
|
$query->where('foods.name', 'like', "%{$term}%")
|
||||||
->orWhere('foods.detail', 'like', "%{$term}%")
|
->orWhere('foods.detail', 'like', "%{$term}%")
|
||||||
->orWhere('foods.brand', 'like', "%{$term}%");
|
->orWhere('foods.brand', 'like', "%{$term}%");
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$this->filterWithScopes($query, $filters);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -44,14 +44,12 @@ class RecipeAdapter extends AbstractAdapter
|
||||||
*/
|
*/
|
||||||
protected function filter($query, Collection $filters)
|
protected function filter($query, Collection $filters)
|
||||||
{
|
{
|
||||||
|
$this->filterWithScopes($query, $filters->except('search'));
|
||||||
if ($term = $filters->get('search')) {
|
if ($term = $filters->get('search')) {
|
||||||
$query->where('recipes.name', 'like', "%{$term}%")
|
$query->where('recipes.name', 'like', "%{$term}%")
|
||||||
->orWhere('recipes.description', 'like', "%{$term}%")
|
->orWhere('recipes.description', 'like', "%{$term}%")
|
||||||
->orWhere('recipes.source', 'like', "%{$term}%");
|
->orWhere('recipes.source', 'like', "%{$term}%");
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$this->filterWithScopes($query, $filters);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue