From aaaa441f65a8ea8c7b46898e25e153a2c3c6948a Mon Sep 17 00:00:00 2001 From: Alec Date: Thu, 18 Mar 2021 10:06:56 +0000 Subject: [PATCH] Add keyword search to product families --- src/Core/Products/Actions/FetchProductFamilies.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Core/Products/Actions/FetchProductFamilies.php b/src/Core/Products/Actions/FetchProductFamilies.php index d64472bfa..b4672be5f 100644 --- a/src/Core/Products/Actions/FetchProductFamilies.php +++ b/src/Core/Products/Actions/FetchProductFamilies.php @@ -30,6 +30,7 @@ public function rules() return [ 'per_page' => 'numeric|max:200', 'paginate' => 'boolean', + 'keywords' => 'nullable', ]; } @@ -48,6 +49,10 @@ public function handle() return $query->get(); } + if ($this->keywords) { + $query->where('name', 'LIKE', "%{$this->keywords}%"); + } + return $query->withCount( $this->resolveRelationCounts() )->paginate($this->per_page ?? 50);