v.2.4
Restore shifts
This commit is contained in:
@@ -20,8 +20,23 @@ class POSTRestoreShift extends HRCCommand implements HRCCommandInterface {
|
|||||||
protected $signature = 'postrestoreshift';
|
protected $signature = 'postrestoreshift';
|
||||||
|
|
||||||
public function command($input, $output = null) {
|
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;
|
$shift_id = 4;
|
||||||
$cache_dir = __DIR__ . "\\..\\..\\..\\Cache\\";
|
$cache_dir = __DIR__ . "\\..\\..\\..\\Cache\\";
|
||||||
|
dirDel($cache_dir);
|
||||||
$terminal_updates_old = TerminalUpdate::where('method', '=', 'online')->get();
|
$terminal_updates_old = TerminalUpdate::where('method', '=', 'online')->get();
|
||||||
foreach ($terminal_updates_old as $key => $terminal_online) {
|
foreach ($terminal_updates_old as $key => $terminal_online) {
|
||||||
$old_date = date_create($terminal_online['next_at']);
|
$old_date = date_create($terminal_online['next_at']);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hrc-admin/hello-world",
|
"name": "hrc-admin/hello-world",
|
||||||
"version": "2.3",
|
"version": "2.4",
|
||||||
"require": {
|
"require": {
|
||||||
"horeca/admin-php-module-core": "dev-master"
|
"horeca/admin-php-module-core": "dev-master"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateTableSubscribers extends Migration {
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up() {
|
||||||
|
Schema::create('subscribers', function (Blueprint $table) {
|
||||||
|
$table->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');
|
||||||
|
}
|
||||||
|
}
|
||||||
29
models/Subscriber.php
Normal file
29
models/Subscriber.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Component\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Subscriber extends Model {
|
||||||
|
protected $table = 'subscribers';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
public static function add($event, $callback, $weight = 0) {
|
||||||
|
list($destination_module, $destination_method) = explode(':', $callback);
|
||||||
|
list($source_module, $source_method) = explode(':', $event);
|
||||||
|
|
||||||
|
$code = strtolower($destination_module . '_' . $destination_method . '_after_' . $source_module . '_' . $source_method);
|
||||||
|
|
||||||
|
if (Subscriber::where('code', $code)->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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
[info]
|
[info]
|
||||||
name=V1
|
name=V1
|
||||||
version=2.3
|
version=2.4
|
||||||
[build]
|
[build]
|
||||||
version=2.3
|
version=2.4
|
||||||
|
|||||||
Reference in New Issue
Block a user