Add category related products

This commit is contained in:
Amanmyrat 2023-09-15 21:31:28 +05:00
parent a8025f1b06
commit 6eee2aaaca
2 changed files with 6 additions and 0 deletions

View File

@ -37,6 +37,11 @@ class Products extends ProductController
return ProductResource::collection($this->productRepository->getAll(request()->input('category')));
}
public function getCurrentProduct(ProductRepository $prodRep, $id)
{
return ProductResource::collection($prodRep->getProductsRelatedToCategoryNurgul($id, request('perPage')));
}
public function home(SliderRepository $sliderRepository,)
{
// $data = [

View File

@ -81,6 +81,7 @@ Route::group(['prefix' => 'api'], function () {
Route::get('products-search', [Products::class, 'searchProducts']);
Route::get('suggestions', [\Sarga\API\Http\Controllers\SearchController::class, 'index']);
Route::get('products/{id}', [Products::class, 'get']);
Route::get('products/related/{id}', [Products::class, 'getCurrentProduct']);
Route::get('products/{id}/variants', [Products::class, 'variants']);
Route::get('states', [ResourceController::class, 'index'])->defaults('_config', [