'DIS', 2 => 'OMHK', 3 => 'MBHK', 4 => 'GBA', 5 => 'YUC', 6 => 'VMHK', 7 => 'ST', 8 => 'RCIM', 9 => 'OMCN', 10 => 'MBCN', 11 => 'PUBLIC' ]; protected string $menuTitle = 'parking_attendant'; // 创建 public function createModel(array $data) { try { DB::beginTransaction(); $model = ParkingAdminUser::query()->create([ 'name' => $data['name'], 'phone' => $data['phone'], 'member_type' => $data['member_type'], 'created_at' => get_datetime() ]); $this->logService->logCreated($model, 'parking_attendant.create'); DB::commit(); return $model; } catch (Exception $e) { DB::rollBack(); throw $e; } } // 创建 public function updateModel(array $data, $id) { try { DB::beginTransaction(); $model = ParkingAdminUser::query()->findOrFail($id); $oldValue = $model->toArray(); $update = [ 'name' => $data['name'], 'phone' => $data['phone'], 'member_type' => $data['member_type'], 'status' => $data['status'] ?? 1, 'updated_at' => get_datetime() ]; $model->update($update); $this->logService->logUpdated( $model, $oldValue, 'parking_attendant.update' ); DB::commit(); return $model; } catch (Exception $e) { DB::rollBack(); throw $e; } } public function deleteModel(int $id): bool { try { DB::beginTransaction(); $model = ParkingAdminUser::query()->findOrFail($id); $this->logService->logDeleted( $model, 'parking_attendant.delete' ); $model->delete(); DB::commit(); return true; } catch (Exception $e) { DB::rollBack(); throw $e; } } }