categories tree
This commit is contained in:
parent
64525fcb0b
commit
18732157b8
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Sarga\API\Http\Controllers;
|
||||
|
||||
use Sarga\API\Http\Resources\Catalog\Category;
|
||||
use Webkul\API\Http\Controllers\Shop\CategoryController;
|
||||
|
||||
class Categories extends CategoryController
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return Category::collection(
|
||||
$this->categoryRepository->getVisibleCategoryTree(request()->input('parent_id'))
|
||||
);
|
||||
}
|
||||
|
||||
public function brands($id)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,16 @@
|
|||
<?php
|
||||
|
||||
use Sarga\API\Http\Controllers\Categories;
|
||||
use Sarga\API\Http\Controllers\Channels;
|
||||
|
||||
Route::group(['prefix' => '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']);
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue