diff --git a/packages/Sarga/API/Http/Controllers/AttributeOptions.php b/packages/Sarga/API/Http/Controllers/AttributeOptions.php new file mode 100644 index 000000000..d0b7d7020 --- /dev/null +++ b/packages/Sarga/API/Http/Controllers/AttributeOptions.php @@ -0,0 +1,39 @@ +has('category')){ - - $categories = $this->categoryRepository->with(['filterableAttributes','brands' => function ($q){ - $q->take(20); - } ]); - - $categories->find($request->get('category')); - - } - } - - public function filters($id){ - $category = $this->categoryRepository->with(['filterableAttributes','children', - 'brands' => function ($q){ - $q->where('status',1); - } ]) - ->find($id); - - if($category) - return response([ - 'subcategories' => Category::collection($category->children), - 'attributes' => Attribute::collection($category->filterableAttributes), - 'brands' => Brand::collection($category->brands), - ]); - else{ - return response(['error'=>'not found'],404); - } - } -} \ No newline at end of file diff --git a/packages/Sarga/API/Http/Controllers/Vendors.php b/packages/Sarga/API/Http/Controllers/Vendors.php index 9d54351d4..f5428355f 100644 --- a/packages/Sarga/API/Http/Controllers/Vendors.php +++ b/packages/Sarga/API/Http/Controllers/Vendors.php @@ -21,7 +21,7 @@ class Vendors extends V1Controller } public function sources(){ - $vendors = $this->vendorRepository->select('marketplace_sellers.id','url','logo','banner','shop_title','brand_attribute_id') + $vendors = $this->vendorRepository->select('marketplace_sellers.id','url','shop_title') ->where('is_approved',true) ->with(['categories:seller_id,type,categories']) // ->leftJoin('seller_categories','marketplace_sellers.id','=','seller_categories.seller_id') diff --git a/packages/Sarga/API/Http/Resources/Catalog/Attribute.php b/packages/Sarga/API/Http/Resources/Catalog/Attribute.php index 6f16ad6b8..d5992430c 100644 --- a/packages/Sarga/API/Http/Resources/Catalog/Attribute.php +++ b/packages/Sarga/API/Http/Resources/Catalog/Attribute.php @@ -18,7 +18,7 @@ class Attribute extends JsonResource 'id' => $this->id, 'code' => $this->code, 'name' => $this->name ?? $this->admin_name, - 'options' => AttributeOption::collection($this->options()->take(40)->get()), + 'options' => AttributeOption::collection($this->options()->take(20)->get()), ]; } diff --git a/packages/Sarga/API/Http/Resources/Core/Source.php b/packages/Sarga/API/Http/Resources/Core/Source.php index 3de3595e1..04f7cf5da 100644 --- a/packages/Sarga/API/Http/Resources/Core/Source.php +++ b/packages/Sarga/API/Http/Resources/Core/Source.php @@ -18,11 +18,9 @@ class Source extends \Illuminate\Http\Resources\Json\JsonResource 'id' => $this->id, 'shop_title' => $this->shop_title, 'logo' => $this->logo_url, - 'banner' => $this->banner_url, $this->mergeWhen(!empty($this->main_categories) && $this->main_categories->count(),[ 'categories' => VendorCategory::collection($this->main_categories) ]) - ]; } } \ No newline at end of file diff --git a/packages/Sarga/API/Http/routes.php b/packages/Sarga/API/Http/routes.php index a184dcc38..815c97285 100644 --- a/packages/Sarga/API/Http/routes.php +++ b/packages/Sarga/API/Http/routes.php @@ -2,6 +2,7 @@ use Illuminate\Support\Facades\Route; use Sarga\API\Http\Controllers\Addresses; +use Sarga\API\Http\Controllers\AttributeOptions; use Sarga\API\Http\Controllers\Carts; use Sarga\API\Http\Controllers\Checkout; use Sarga\API\Http\Controllers\Customers; @@ -37,11 +38,9 @@ Route::group(['prefix' => 'api'], function () { //category routes Route::get('descendant-categories', [Categories::class, 'descendantCategories'])->name('api.descendant-categories'); - Route::get('categories', [ResourceController::class, 'index'])->defaults('_config', [ - 'repository' => CategoryRepository::class, - 'resource' => Category::class, - ])->name('api.categories'); + Route::get('categories', [Categories::class, 'allResources'])->name('api.categories'); Route::get('categories/{id}/filters',[Categories::class,'filters']); + Route::get('attribute-options', [AttributeOptions::class, 'allResources']); //attributes by code Route::get('attribute-options', [ResourceController::class, 'index'])->defaults('_config', [