属性下拉

This commit is contained in:
2025-06-17 17:16:06 +08:00
parent fee2241317
commit 2a0bfc92cb
3 changed files with 31 additions and 0 deletions
@@ -55,6 +55,12 @@ class VehicleNewAttributesController extends BaseController
}
return $result;
}
if ($scene === 'preset') {
return [
'id' => $item['id'],
'attribute_name' => isset($item['translation']) ? $item['translation']['attribute_name'] : '',
];
}
return $item;
}
@@ -102,6 +108,15 @@ class VehicleNewAttributesController 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().$th->getLine().$th->getFile());
}
}
public function edit(Request $request, int $id): Response
{
try {
@@ -48,6 +48,21 @@ class VehicleNewAttributesService extends BaseService
]
];
},
'preset' => function ($params) {
return [
'filters' => [
],
'fields' => ['id','status'],
'relations' => [
'translation' => ['attributes_id', 'locale', 'attribute_name'],
'value' => ['id', 'attribute_id', 'sort_order'],
'value.translation' => ['id', 'values_id', 'locale', 'value_name'],
],
'sorts' => [
['field' => 'created_at', 'direction' => 'desc']
],
];
},
'show' => function ($params) {
return [
'filters' => [
+1
View File
@@ -194,6 +194,7 @@ Route::group('/console', function() {
//新车属性
Route::any('/vehicle/new/attributes/list', [\app\console\controller\VehicleNewAttributesController::class, 'index']);
Route::any('/vehicle/new/attributes/preset', [\app\console\controller\VehicleNewAttributesController::class, 'presets']);
Route::any('/vehicle/new/attributes/add', [\app\console\controller\VehicleNewAttributesController::class, 'add']);
Route::any('/vehicle/new/attributes/{id}/update', [\app\console\controller\VehicleNewAttributesController::class, 'edit']);
Route::any('/vehicle/new/attributes/{id}/delete', [\app\console\controller\VehicleNewAttributesController::class, 'destroy']);