Browse Source

车位属性更改 创建、编辑、删除、查看逻辑2

master
wanghongjun 4 weeks ago
parent
commit
000255b39d
  1. 4
      app/Http/Controllers/Admin/ParkingSpaceTypeController.php
  2. 7
      app/Models/ParkingSpaceAttributes.php
  3. 1
      database/migrations/2026_03_05_144951_create_parking_space_attributes_table.php

4
app/Http/Controllers/Admin/ParkingSpaceTypeController.php

@ -77,7 +77,7 @@ class ParkingSpaceTypeController extends BaseController
try { try {
$data = [ $data = [
'color_list' => $this->SpaceTypeService->getColorList(), 'color_list' => $this->SpaceTypeService->getColorList(),
'attr_list' => ParkingSpaceAttributes::getList() 'attr_list' => ParkingSpaceAttributes::getTypeList()
]; ];
return $this->responseService->success($data); return $this->responseService->success($data);
} catch (Exception $e) { } catch (Exception $e) {
@ -155,7 +155,7 @@ class ParkingSpaceTypeController extends BaseController
$item['attributes'] = ParkingSpaceTypeAttrService::getTypeAttrData($item['id']); $item['attributes'] = ParkingSpaceTypeAttrService::getTypeAttrData($item['id']);
$data = [ $data = [
'color_list' => $this->SpaceTypeService->getColorList(), 'color_list' => $this->SpaceTypeService->getColorList(),
'attr_list' => ParkingSpaceAttributes::getList(), 'attr_list' => ParkingSpaceAttributes::getTypeList(),
'item' => $item 'item' => $item
]; ];
return $this->responseService->success($data); return $this->responseService->success($data);

7
app/Models/ParkingSpaceAttributes.php

@ -33,6 +33,13 @@ class ParkingSpaceAttributes extends Model
)->toArray(); )->toArray();
} }
public static function getTypeList(): array
{
return self::query()->where('is_default', 0)->get()->select(
['id', 'attributes']
)->toArray();
}
public static function getAttr($id) public static function getAttr($id)
{ {
return self::query()->where('id', $id)->value('attributes') ?? ''; return self::query()->where('id', $id)->value('attributes') ?? '';

1
database/migrations/2026_03_05_144951_create_parking_space_attributes_table.php

@ -15,6 +15,7 @@ return new class extends Migration
$table->id(); $table->id();
$table->string('attributes', 50)->comment('车位属性'); $table->string('attributes', 50)->comment('车位属性');
$table->string('import_diagram', 255)->comment('汇入图示'); $table->string('import_diagram', 255)->comment('汇入图示');
$table->tinyInteger('is_default')->default(0)->comment('是否默认');
$table->timestamps(); $table->timestamps();
$table->softDeletes(); $table->softDeletes();
$table->innoDb(); $table->innoDb();

Loading…
Cancel
Save