diff --git a/packages/Sarga/API/Http/Controllers/Categories.php b/packages/Sarga/API/Http/Controllers/Categories.php new file mode 100644 index 000000000..3d57041de --- /dev/null +++ b/packages/Sarga/API/Http/Controllers/Categories.php @@ -0,0 +1,21 @@ +categoryRepository->getVisibleCategoryTree(request()->input('parent_id')) + ); + } + + public function brands($id) + { + + } +} \ No newline at end of file diff --git a/packages/Sarga/API/Http/Resources/Catalog/Category.php b/packages/Sarga/API/Http/Resources/Catalog/Category.php index 88dde44c6..1c3fa7768 100644 --- a/packages/Sarga/API/Http/Resources/Catalog/Category.php +++ b/packages/Sarga/API/Http/Resources/Catalog/Category.php @@ -17,20 +17,20 @@ class Category extends JsonResource { return [ 'id' => $this->id, - 'code' => $this->code, +// 'code' => $this->code, 'name' => $this->name, - 'slug' => $this->slug, - 'display_mode' => $this->display_mode, +// 'slug' => $this->slug, +// 'display_mode' => $this->display_mode, 'description' => $this->description, - 'status' => $this->status, +// 'status' => $this->status, 'image_url' => $this->image_url, 'category_icon_path' => $this->category_icon_path ? Storage::url($this->category_icon_path) : null, - 'additional' => is_array($this->resource->additional) - ? $this->resource->additional - : json_decode($this->resource->additional, true), - +// 'additional' => is_array($this->resource->additional) +// ? $this->resource->additional +// : json_decode($this->resource->additional, true), + 'children' => Category::collection($this->children) ]; } } diff --git a/packages/Sarga/API/Http/routes.php b/packages/Sarga/API/Http/routes.php index b16d0eb23..8357ec301 100644 --- a/packages/Sarga/API/Http/routes.php +++ b/packages/Sarga/API/Http/routes.php @@ -1,10 +1,16 @@ 'api'], function ($router) { Route::group(['middleware' => ['locale', 'currency']], function ($router) { //Channel routes Route::get('channels',[Channels::class, 'index']); - Route::get('channels/{channel_id}',[Channels::class, 'get']); + + //category routes + Route::get('descendant-categories', [Categories::class, 'index']); + Route::get('category-brands/{id}', [Categories::class, 'brands']); + }); });