search suggestions start

This commit is contained in:
merdan 2022-04-16 15:30:31 +05:00
parent 976ef63810
commit 30fb46db2a
2 changed files with 4 additions and 4 deletions

View File

@ -113,7 +113,7 @@ class Products extends ProductController
return response()->json(['message' => 'not found'],404);
}
public function search(BrandRepository $brandRepository){
public function suggestions(BrandRepository $brandRepository){
$key = request('search');
@ -128,9 +128,9 @@ class Products extends ProductController
->limit(10)
->get();
$products = $this->productRepository->getAll()->only('id','name');
// $products = $this->productRepository->getAll()->only('id','name');
return $products;
return $brands;
if($brands->count() >0){
foreach($brands as $brand) {

View File

@ -51,7 +51,7 @@ Route::group(['prefix' => 'api'], function () {
//Product routes
Route::get('products', [Products::class, 'index']);
Route::get('products/search', [Products::class, 'search']);
Route::get('products/search', [Products::class, 'suggestions']);
Route::get('products/{id}', [Products::class, 'get']);
Route::get('products/{id}/variants', [Products::class, 'variants']);