category filters
This commit is contained in:
parent
45648904a8
commit
1f277be89c
|
|
@ -3,6 +3,7 @@
|
|||
namespace Sarga\API\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Sarga\API\Http\Resources\Catalog\Attribute;
|
||||
use Sarga\API\Http\Resources\Catalog\Category;
|
||||
use Sarga\Shop\Repositories\CategoryRepository;
|
||||
|
||||
|
|
@ -33,4 +34,14 @@ class Categories extends Controller
|
|||
|
||||
}
|
||||
|
||||
public function filters($id){
|
||||
$category = $this->categoryRepository->with('filterableAttributes')->find($id);
|
||||
|
||||
if($category)
|
||||
return Attribute::collection($category->filterableAttributes);
|
||||
else{
|
||||
return response()->json(['error'=>'not found'],404);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -33,6 +33,7 @@ Route::group(['prefix' => 'api'], function ($router) {
|
|||
'repository' => CategoryRepository::class,
|
||||
'resource' => Category::class,
|
||||
])->name('api.categories');
|
||||
Route::get('categories/{id}/filters',[Categories::class,'filters']);
|
||||
//attributes by code
|
||||
Route::get('attribute-options', [ResourceController::class, 'index'])->defaults('_config', [
|
||||
'repository' => AttributeOptionRepository::class,
|
||||
|
|
|
|||
Loading…
Reference in New Issue