Add limit option to food search

This commit is contained in:
Christopher C. Wells 2021-01-20 05:09:17 -08:00
parent 5877d24f64
commit 67febe7a34
1 changed files with 2 additions and 2 deletions

View File

@ -107,7 +107,7 @@ class Food extends Model
/**
* Gets search results for a term.
*/
public static function search(string $term): Collection {
return (new static)::where('name', 'like', "%{$term}%")->get();
public static function search(string $term, int $limit = 10): Collection {
return (new static)::where('name', 'like', "%{$term}%")->limit($limit)->get();
}
}