search suggestions start
This commit is contained in:
parent
1c5ed87379
commit
976ef63810
|
|
@ -5,6 +5,7 @@ namespace Sarga\API\Http\Controllers;
|
|||
use Illuminate\Support\Facades\Log;
|
||||
use Sarga\API\Http\Resources\Catalog\ProductVariant;
|
||||
use Sarga\API\Http\Resources\Catalog\SuperAttribute;
|
||||
use Sarga\Brand\Repositories\BrandRepository;
|
||||
use Sarga\Shop\Repositories\ProductRepository;
|
||||
use Webkul\API\Http\Controllers\Shop\ProductController;
|
||||
use Sarga\API\Http\Resources\Catalog\Product as ProductResource;
|
||||
|
|
@ -112,4 +113,31 @@ class Products extends ProductController
|
|||
return response()->json(['message' => 'not found'],404);
|
||||
}
|
||||
|
||||
public function search(BrandRepository $brandRepository){
|
||||
|
||||
$key = request('search');
|
||||
|
||||
if(!strlen($key)>= 3){
|
||||
return response()->json(['message' => '3 karakterden kuchuk','status'=>false]);
|
||||
}
|
||||
|
||||
$brands = $brandRepository->select('id','name')
|
||||
->where('status',1)
|
||||
->where('name','like','%' . urldecode($key) . '%')
|
||||
->orderBy('name','asc')
|
||||
->limit(10)
|
||||
->get();
|
||||
|
||||
$products = $this->productRepository->getAll()->only('id','name');
|
||||
|
||||
return $products;
|
||||
|
||||
if($brands->count() >0){
|
||||
foreach($brands as $brand) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class AddressRequest extends CustomerAddressRequest
|
|||
public function rules()
|
||||
{
|
||||
return [
|
||||
'note' => [new AlphaNumericSpace,'max:191'],
|
||||
'note' => ['max:191'],
|
||||
'address1' => ['required', 'array'],
|
||||
// 'state' => ['required', new AlphaNumericSpace],
|
||||
'city' => ['required'],
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ class RecipientRequest extends CustomerAddressRequest
|
|||
public function rules()
|
||||
{
|
||||
return [
|
||||
'first_name' => ['required', new AlphaNumericSpace],
|
||||
'last_name' => ['required', new AlphaNumericSpace],
|
||||
'first_name' => ['required'],
|
||||
'last_name' => ['required'],
|
||||
'phone' => ['required', new PhoneNumber],
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +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/{id}', [Products::class, 'get']);
|
||||
Route::get('products/{id}/variants', [Products::class, 'variants']);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue