This commit is contained in:
merdan 2021-10-28 21:36:04 +05:00
parent e5b75a92ef
commit 6d53ddd200
3 changed files with 8 additions and 26 deletions

View File

@ -1,19 +0,0 @@
<?php
namespace Sarga\API\Http\Controllers;
use Webkul\API\Http\Controllers\Shop\ResourceController;
class Resources extends ResourceController
{
public function get($code){
$query = isset($this->_config['authorization_required']) && $this->_config['authorization_required'] ?
$this->repository->where(['customer_id'=>auth()->user()->id,'code'=>$code])->first() :
$this->repository->where('code',$code)->first();
if($query)
return new $this->_config['resource']($query);
else
return response()->json(['status'=>false,'message'=>'Not found'],404);
}
}

View File

@ -23,7 +23,8 @@ class Channel extends JsonResource
'hostname' => $this->hostname,
'root_category_id' => $this->root_category_id,
'is_maintenance_on' => $this->is_maintenance_on,
'sliders' => Slider::collection($this->sliders)
'sliders' => Slider::collection($this->sliders),
'brand_attribute_id' => 25 //todo vremenno goyuldy. id admindan bazadan settingsden almaly(2 marketplace goshulanda)
// '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))

View File

@ -2,9 +2,9 @@
use Sarga\API\Http\Controllers\Categories;
use Sarga\API\Http\Controllers\Channels;
use Sarga\API\Http\Controllers\Resources;
use Webkul\Attribute\Repositories\AttributeRepository;
use Sarga\API\Http\Resources\Catalog\Attribute;
use Webkul\API\Http\Controllers\Shop\ResourceController;
use Webkul\Attribute\Repositories\AttributeOptionRepository;
use Sarga\API\Http\Resources\Catalog\AttributeOption;
Route::group(['prefix' => 'api'], function ($router) {
Route::group(['middleware' => ['locale', 'currency']], function ($router) {
@ -16,9 +16,9 @@ Route::group(['prefix' => 'api'], function ($router) {
Route::get('category-brands/{id}', [Categories::class, 'brands']);
//attributes by code
Route::get('attribute-by-code/{code}', [Resources::class, 'get'])->defaults('_config', [
'repository' => AttributeRepository::class,
'resource' => Attribute::class,
Route::get('attribute-options', [ResourceController::class, 'index'])->defaults('_config', [
'repository' => AttributeOptionRepository::class,
'resource' => AttributeOption::class,
]);
});