dist_id = $distId; $model->file_name = $fileName; $model->file_path = $filePath; $model->appearance_id = $appearanceId; $model->template_code = $templateCode; $model->current_content = $currentContent; $model->previous_content = $previousContent; $model->version = generateVersionNumber(); $model->save(); } /* * 获取模版修改日志 */ public static function fetchTemplateLogs($appearanceId,$distId,$templateCode) { $model = new Model(); $model = $model->where('appearance_id','=',$appearanceId)->where('dist_id','=',$distId)->where('template_code','=',$templateCode)->orderBy('id','desc')->select('id','version','created_at')->get(); return $model; } /* * 获取单条模版修改日志内容 */ public static function fetchTemplateLogContent($logId) { $model = new Model(); $model = $model->where('id','=',$logId)->first(); return $model; } /* * 还原模版 */ public static function restoreTemplateLog($logId) { $model = new Model(); $model = $model->where('id', '=', $logId)->first(); if ($model) { $appearanceId = $model->appearance_id; $distId = $model->dist_id; $templateCode = $model->template_code; $content = $model->previous_content; DistAppearanceTemplate::saveContent($appearanceId, $distId, $templateCode, $content); } } }