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