From ac1ec3316b4dd58bc3c83da7310e218baaa9c763 Mon Sep 17 00:00:00 2001 From: "Christopher C. Wells" Date: Wed, 20 Jan 2021 05:09:17 -0800 Subject: [PATCH] Add limit option to food search --- app/Models/Food.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/Food.php b/app/Models/Food.php index d357ba6..0208336 100644 --- a/app/Models/Food.php +++ b/app/Models/Food.php @@ -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(); } }