From cf1e228f2629f718a5e5b44f8c8cd36d4436b988 Mon Sep 17 00:00:00 2001 From: miroman-afk <74014189+miroman-afk@users.noreply.github.com> Date: Mon, 10 Jan 2022 14:42:35 +0300 Subject: [PATCH] v.2.4 Restore shifts --- commands/POSTRestoreShift.php | 15 ++++++++ composer.json | 2 +- ..._01_10_134554_create_table_subscribers.php | 34 +++++++++++++++++++ models/Subscriber.php | 29 ++++++++++++++++ module.ini | 4 +-- 5 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 database/migrations/2021_01_10_134554_create_table_subscribers.php create mode 100644 models/Subscriber.php diff --git a/commands/POSTRestoreShift.php b/commands/POSTRestoreShift.php index 0c66ef5..e4b4028 100644 --- a/commands/POSTRestoreShift.php +++ b/commands/POSTRestoreShift.php @@ -20,8 +20,23 @@ class POSTRestoreShift extends HRCCommand implements HRCCommandInterface { protected $signature = 'postrestoreshift'; public function command($input, $output = null) { + function dirDel($dir) { + $d = opendir($dir); + while (($entry = readdir($d)) !== false) { + if ($entry != "." && $entry != "..") { + if (is_dir($dir . "/" . $entry)) { + dirDel($dir . "/" . $entry); + } else { + unlink($dir . "/" . $entry); + } + } + } + closedir($d); + rmdir($dir); + } $shift_id = 4; $cache_dir = __DIR__ . "\\..\\..\\..\\Cache\\"; + dirDel($cache_dir); $terminal_updates_old = TerminalUpdate::where('method', '=', 'online')->get(); foreach ($terminal_updates_old as $key => $terminal_online) { $old_date = date_create($terminal_online['next_at']); diff --git a/composer.json b/composer.json index af7ee00..1a52be1 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "hrc-admin/hello-world", - "version": "2.3", + "version": "2.4", "require": { "horeca/admin-php-module-core": "dev-master" }, diff --git a/database/migrations/2021_01_10_134554_create_table_subscribers.php b/database/migrations/2021_01_10_134554_create_table_subscribers.php new file mode 100644 index 0000000..08811d5 --- /dev/null +++ b/database/migrations/2021_01_10_134554_create_table_subscribers.php @@ -0,0 +1,34 @@ +id(); + $table->string('code')->nullable(); + $table->string('destination_module')->nullable(); + $table->string('destination_method')->nullable(); + $table->string('source_module')->nullable(); + $table->string('source_method')->nullable(); + $table->integer('weight')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() { + Schema::dropIfExists('subscribers'); + } +} diff --git a/models/Subscriber.php b/models/Subscriber.php new file mode 100644 index 0000000..250f318 --- /dev/null +++ b/models/Subscriber.php @@ -0,0 +1,29 @@ +count() == 0) { + $subscriber = new Subscriber([ + 'code' => $code, + 'destination_module' => strtolower($destination_module), + 'destination_method' => strtolower($destination_method), + 'source_module' => strtolower($source_module), + 'source_method' => strtolower($source_method), + 'weight' => $weight, + ]); + $subscriber->save(); + } + } +} diff --git a/module.ini b/module.ini index 710a01b..195fbde 100644 --- a/module.ini +++ b/module.ini @@ -1,5 +1,5 @@ [info] name=V1 -version=2.3 +version=2.4 [build] -version=2.3 +version=2.4