diff --git a/app/console/controller/VehicleNewAttributeCategoriesController.php b/app/console/controller/VehicleNewAttributeCategoriesController.php index baa98a2..de24242 100644 --- a/app/console/controller/VehicleNewAttributeCategoriesController.php +++ b/app/console/controller/VehicleNewAttributeCategoriesController.php @@ -39,7 +39,7 @@ class VehicleNewAttributeCategoriesController extends BaseController */ protected function postProcessItem(array $item, string $scene): array { - if ($scene === 'default' || $scene === 'show') { + if ($scene === 'default' || $scene === 'show' || $scene === 'preset') { $result = [ 'id' => $item['id'], 'sort_order' => $item['sort_order'], @@ -84,6 +84,15 @@ class VehicleNewAttributeCategoriesController extends BaseController } } + public function presets(Request $request, string $scene = 'preset'): Response + { + try { + return parent::all($request, $scene); + } catch (\Throwable $th) { + return $this->errorResponse($th->getMessage()); + } + } + public function add(Request $request): Response { diff --git a/app/console/service/VehicleNewAttributeCategoriesService.php b/app/console/service/VehicleNewAttributeCategoriesService.php index 1c6a30a..4d3bb4f 100644 --- a/app/console/service/VehicleNewAttributeCategoriesService.php +++ b/app/console/service/VehicleNewAttributeCategoriesService.php @@ -47,6 +47,21 @@ class VehicleNewAttributeCategoriesService extends BaseService ] ]; }, + 'preset' => function ($params) { + return [ + 'filters' => [ + ], + 'fields' => ['id','sort_order'], + 'relations' => [ + 'translation' => ['categories_id', 'locale', 'category_name'], + 'attribute' => ['id','status'], + 'attribute.translation' => ['attributes_id', 'locale', 'attribute_name'], + ], + 'sorts' => [ + ['field' => 'created_at', 'direction' => 'desc'] + ], + ]; + }, 'show' => function ($params) { return [ 'filters' => [ @@ -104,6 +119,7 @@ class VehicleNewAttributeCategoriesService extends BaseService public function edit(array $params, int $id) { $sourceLocale = locale(); + var_dump($params); $sourceFields = $this->extractSourceFields($params); if (empty($sourceFields)) { diff --git a/config/route.php b/config/route.php index dc6bd31..45b0d0f 100644 --- a/config/route.php +++ b/config/route.php @@ -202,6 +202,7 @@ Route::group('/console', function() { //新车属性分类 Route::any('/vehicle/new/categories/list', [\app\console\controller\VehicleNewAttributeCategoriesController::class, 'index']); + Route::any('/vehicle/new/categories/preset', [\app\console\controller\VehicleNewAttributeCategoriesController::class, 'presets']); Route::any('/vehicle/new/categories/add', [\app\console\controller\VehicleNewAttributeCategoriesController::class, 'add']); Route::any('/vehicle/new/categories/{id}/update', [\app\console\controller\VehicleNewAttributeCategoriesController::class, 'edit']); Route::any('/vehicle/new/categories/{id}/delete', [\app\console\controller\VehicleNewAttributeCategoriesController::class, 'destroy']);