From 6c0987b90e71dc820ece28bb4c090eeef37220d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Cmit=20Tun=C3=A7?= Date: Tue, 28 Apr 2026 22:09:11 +0300 Subject: [PATCH] feat: add migration to seed default application settings --- ...28_220700_add_common_settings_defaults.php | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 database/migrations/2026_04_28_220700_add_common_settings_defaults.php diff --git a/database/migrations/2026_04_28_220700_add_common_settings_defaults.php b/database/migrations/2026_04_28_220700_add_common_settings_defaults.php new file mode 100644 index 0000000..72858bf --- /dev/null +++ b/database/migrations/2026_04_28_220700_add_common_settings_defaults.php @@ -0,0 +1,67 @@ + 'Citrus CMS', + 'project_name_ru' => '', + 'project_number' => '', + 'company_code' => '', + 'row_count' => '20', + 'summary_mails' => '', + 'cron_job_batch_process_count' => '10', + 'cron_job_period' => '1', + 'gemini_api_key' => '', + 'header_color' => 'bg-primary-dark', + 'DevExpress_Theme' => 'dx.material.orange.light.compact.css', + 'pdf_template_path' => 'default', + ]; + + foreach ($settings as $key => $value) { + // Check if setting already exists + $exists = DB::table('settings')->where('title', $key)->exists(); + + if (!$exists) { + DB::table('settings')->insert([ + 'title' => $key, + 'html' => $value, + 'created_at' => now(), + 'updated_at' => now(), + ]); + } + } + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + $keys = [ + 'project_name', + 'project_name_ru', + 'project_number', + 'company_code', + 'row_count', + 'summary_mails', + 'cron_job_batch_process_count', + 'cron_job_period', + 'gemini_api_key', + 'header_color', + 'DevExpress_Theme', + 'pdf_template_path', + 'handover_control_count', + ]; + + DB::table('settings')->whereIn('title', $keys)->delete(); + } +};