where('appearance_id', $appearanceId)->count(); if ($count > 0) { return; } //复制 DB::statement(" INSERT INTO `dist_appearance_template` (`dist_id`, `appearance_id`, `file_name`, `file_path`, `content`, `created_at`, `updated_at`, `template_code`) SELECT {$distId}, `appearance_id`, `file_name`, `file_path`, `content`, NOW(), NOW(), `template_code` FROM `dist_appearance_template` WHERE `dist_id` = 0 AND `appearance_id` = {$appearanceId}; "); } public static function deleteTemplates($appearanceId,$distId) { self::where('dist_id',$distId)->where('appearance_id',$appearanceId)->delete(); return true; } }