diff --git a/composer.json b/composer.json index ef0fa5042..6bcc8e1ac 100755 --- a/composer.json +++ b/composer.json @@ -105,7 +105,8 @@ "Webkul\\SocialLogin\\": "packages/Webkul/SocialLogin/src", "Webkul\\DebugBar\\": "packages/Webkul/DebugBar/src", "Webkul\\Marketing\\": "packages/Webkul/Marketing/src", - "Sarga\\Shop\\": "packages/Sarga/Shop/src" + "Sarga\\Shop\\": "packages/Sarga/Shop/src", + "Sarga\\API\\": "packages/Sarga/API" } }, "autoload-dev": { diff --git a/config/app.php b/config/app.php index cc79426c2..d0674a98f 100755 --- a/config/app.php +++ b/config/app.php @@ -282,6 +282,8 @@ return [ Webkul\SocialLogin\Providers\SocialLoginServiceProvider::class, Webkul\DebugBar\Providers\DebugBarServiceProvider::class, Webkul\Marketing\Providers\MarketingServiceProvider::class, + Sarga\Shop\Providers\ShopServiceProvider::class, + Sarga\API\Providers\APIServiceProvider::class ], /* diff --git a/packages/Sarga/API/Http/Controllers/Channels.php b/packages/Sarga/API/Http/Controllers/Channels.php new file mode 100644 index 000000000..e9d6d14f3 --- /dev/null +++ b/packages/Sarga/API/Http/Controllers/Channels.php @@ -0,0 +1,36 @@ +channelRepository = $channelRepository; + + } + + public function index() + { + + $channels = $this->channelRepository->with('sliders')->get(); + + if($channels) + { + return Channel::collection($channels); + } + else + { + return response()->json(['not found'],404); + } + } + + public function get($channel_id){ + $this->categoryRepository->getVisibleCategoryTree(request()->input('parent_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 new file mode 100644 index 000000000..88dde44c6 --- /dev/null +++ b/packages/Sarga/API/Http/Resources/Catalog/Category.php @@ -0,0 +1,36 @@ + $this->id, + 'code' => $this->code, + 'name' => $this->name, + 'slug' => $this->slug, + 'display_mode' => $this->display_mode, + 'description' => $this->description, + '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), + + ]; + } +} diff --git a/packages/Sarga/API/Http/Resources/Core/Channel.php b/packages/Sarga/API/Http/Resources/Core/Channel.php new file mode 100644 index 000000000..e8bd2c3b7 --- /dev/null +++ b/packages/Sarga/API/Http/Resources/Core/Channel.php @@ -0,0 +1,32 @@ + $this->id, + 'code' => $this->code, + 'name' => $this->name, + 'hostname' => $this->hostname, + 'root_category_id' => $this->root_category_id, + 'is_maintenance_on' => $this->is_maintenance_on, + 'sliders' => Slider::collection($this->sliders) +// 'root_category' => $this->when($this->root_category_id, new CategoryResource($this->root_category)), +// 'main_categories' => $this->when(request()->has('channel_id'),Category::collection($this->categories)) + + ]; + } +} \ No newline at end of file diff --git a/packages/Sarga/API/Http/Resources/Core/Slider.php b/packages/Sarga/API/Http/Resources/Core/Slider.php new file mode 100644 index 000000000..dd3e38b7f --- /dev/null +++ b/packages/Sarga/API/Http/Resources/Core/Slider.php @@ -0,0 +1,27 @@ + $this->id, + 'title' => $this->title, + 'image_url' => $this->image_url, + 'content' => $this->content, + 'expired_at'=> $this->expired_at, + 'sort_order'=> $this->sort_order, + 'slider_path'=>$this->slider_path + ]; + } +} \ No newline at end of file diff --git a/packages/Sarga/API/Http/routes.php b/packages/Sarga/API/Http/routes.php new file mode 100644 index 000000000..b16d0eb23 --- /dev/null +++ b/packages/Sarga/API/Http/routes.php @@ -0,0 +1,10 @@ + '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']); + }); +}); diff --git a/packages/Sarga/API/Providers/APIServiceProvider.php b/packages/Sarga/API/Providers/APIServiceProvider.php new file mode 100644 index 000000000..12096e054 --- /dev/null +++ b/packages/Sarga/API/Providers/APIServiceProvider.php @@ -0,0 +1,17 @@ +loadRoutesFrom(__DIR__.'/../Http/routes.php'); + } +} \ No newline at end of file diff --git a/packages/Sarga/API/composer.json b/packages/Sarga/API/composer.json new file mode 100644 index 000000000..e1a3340c5 --- /dev/null +++ b/packages/Sarga/API/composer.json @@ -0,0 +1,30 @@ +{ + "name": "sarga/api", + "description": "API for Sarga.", + "license": "MIT", + + "authors": [ + { + "name": "merdan muhammedow", + "email": "merdan.m@gmail.com" + } + ], + + "require": {}, + "autoload": { + "psr-4": { + "Sarga\\Shop\\": "src/" + } + }, + + "extra": { + "laravel": { + "providers": [ + "Sarga\\API\\Providers\\APIerviceProvider" + ], + "aliases": {} + } + }, + + "minimum-stability": "dev" +} diff --git a/packages/Sarga/Shop/src/Models/Channel.php b/packages/Sarga/Shop/src/Models/Channel.php new file mode 100644 index 000000000..70717affd --- /dev/null +++ b/packages/Sarga/Shop/src/Models/Channel.php @@ -0,0 +1,11 @@ +hasMany(SliderProxy::modelClass()); + } +} \ No newline at end of file diff --git a/packages/Sarga/Shop/src/Models/ChannelTranslation.php b/packages/Sarga/Shop/src/Models/ChannelTranslation.php new file mode 100644 index 000000000..fe7de38d7 --- /dev/null +++ b/packages/Sarga/Shop/src/Models/ChannelTranslation.php @@ -0,0 +1,9 @@ + 'api'], function ($router) { //Channel routes Route::get('channels', [ResourceController::class, 'index'])->defaults('_config', [ 'repository' => ChannelRepository::class, - 'resource' => Channel::class, + 'resource' => ChannelResource::class, ]); Route::get('channels/{id}', [ResourceController::class, 'get'])->defaults('_config', [ 'repository' => ChannelRepository::class, - 'resource' => Channel::class, + 'resource' => ChannelResource::class, ]);