From 3390b48ea62dd3dac602e01b44189a4058b43358 Mon Sep 17 00:00:00 2001 From: tm8544 <15167679+tm8544@users.noreply.github.com> Date: Wed, 15 May 2024 14:57:53 +0300 Subject: [PATCH] Add files via upload --- .../004_add_date_format_setting.php | 42 +++++++++++++++++++ .../059_new_date_format_setting.php | 37 ++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 application/migrations/004_add_date_format_setting.php create mode 100644 application/migrations/059_new_date_format_setting.php diff --git a/application/migrations/004_add_date_format_setting.php b/application/migrations/004_add_date_format_setting.php new file mode 100644 index 00000000..ea92c184 --- /dev/null +++ b/application/migrations/004_add_date_format_setting.php @@ -0,0 +1,42 @@ + + * @copyright Copyright (c) Alex Tselegidis + * @license https://opensource.org/licenses/GPL-3.0 - GPLv3 + * @link https://easyappointments.org + * @since v1.1.0 + * ---------------------------------------------------------------------------- */ + +class Migration_Add_date_format_setting extends EA_Migration +{ + /** + * Upgrade method. + * + * @throws Exception + */ + public function up() + { + if (!$this->db->get_where('settings', ['name' => 'date_format'])->num_rows()) { + $this->db->insert('settings', [ + 'name' => 'date_format', + 'value' => 'DMY', + ]); + } + } + + /** + * Downgrade method. + * + * @throws Exception + */ + public function down() + { + if ($this->db->get_where('settings', ['name' => 'date_format'])->num_rows()) { + $this->db->delete('settings', ['name' => 'date_format']); + } + } +} diff --git a/application/migrations/059_new_date_format_setting.php b/application/migrations/059_new_date_format_setting.php new file mode 100644 index 00000000..af46ea90 --- /dev/null +++ b/application/migrations/059_new_date_format_setting.php @@ -0,0 +1,37 @@ + + * @copyright Copyright (c) Alex Tselegidis + * @license https://opensource.org/licenses/GPL-3.0 - GPLv3 + * @link https://easyappointments.org + * @since v1.1.0 + * ---------------------------------------------------------------------------- */ + +class Migration_Add_date_format_setting extends EA_Migration +{ + /** + * Upgrade method. + * + * @throws Exception + */ + public function up() + { + $this->db->update('settings', ['value' => 'DD.MM.YYYY'], ['name' => 'date_format']); + } + + /** + * Downgrade method. + * + * @throws Exception + */ + public function down() + { + if ($this->db->get_where('settings', ['name' => 'date_format'])->num_rows()) { + $this->db->delete('settings', ['name' => 'date_format']); + } + } +}