mirror of https://github.com/kcal-app/kcal.git
Add limit option to food search
This commit is contained in:
parent
5877d24f64
commit
67febe7a34
|
|
@ -107,7 +107,7 @@ class Food extends Model
|
||||||
/**
|
/**
|
||||||
* Gets search results for a term.
|
* Gets search results for a term.
|
||||||
*/
|
*/
|
||||||
public static function search(string $term): Collection {
|
public static function search(string $term, int $limit = 10): Collection {
|
||||||
return (new static)::where('name', 'like', "%{$term}%")->get();
|
return (new static)::where('name', 'like', "%{$term}%")->limit($limit)->get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue