From bb5beda21797dd49646b328b5aa4d7f2cbdf6170 Mon Sep 17 00:00:00 2001 From: merdan Date: Sun, 17 Apr 2022 16:25:55 +0500 Subject: [PATCH] search suggestions finish --- .../Sarga/API/Http/Controllers/Products.php | 3 ++- .../API/Http/Resources/Catalog/Suggestion.php | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 packages/Sarga/API/Http/Resources/Catalog/Suggestion.php diff --git a/packages/Sarga/API/Http/Controllers/Products.php b/packages/Sarga/API/Http/Controllers/Products.php index 7c5c7061a..278990382 100644 --- a/packages/Sarga/API/Http/Controllers/Products.php +++ b/packages/Sarga/API/Http/Controllers/Products.php @@ -6,6 +6,7 @@ use Illuminate\Support\Arr; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; use Sarga\API\Http\Resources\Catalog\ProductVariant; +use Sarga\API\Http\Resources\Catalog\Suggestion; use Sarga\API\Http\Resources\Catalog\SuperAttribute; use Sarga\Brand\Repositories\BrandRepository; use Sarga\Shop\Repositories\ProductRepository; @@ -163,7 +164,7 @@ class Products extends ProductController } - return $products->merge($brands)->sortBy('name'); + return Suggestion::collection($products->merge($brands)->sortBy('name')); } diff --git a/packages/Sarga/API/Http/Resources/Catalog/Suggestion.php b/packages/Sarga/API/Http/Resources/Catalog/Suggestion.php new file mode 100644 index 000000000..d700f20d4 --- /dev/null +++ b/packages/Sarga/API/Http/Resources/Catalog/Suggestion.php @@ -0,0 +1,23 @@ + $this->id, + 'type' => $this->type, + 'name' => $this->name, + ]; + } +} \ No newline at end of file