@@ -3,7 +3,6 @@ |
||
| 3 | 3 | namespace App\Console\Commands; |
| 4 | 4 | |
| 5 | 5 | use Illuminate\Console\Command; |
| 6 | -use Storage; |
|
| 7 | 6 | |
| 8 | 7 | class Export extends Command |
| 9 | 8 | { |
@@ -23,9 +23,9 @@ discard block |
||
| 23 | 23 | protected $description = 'Export accounts, groups and categories at once'; |
| 24 | 24 | |
| 25 | 25 | protected $commands = [ |
| 26 | - 'export:accounts', |
|
| 27 | - 'export:groups', |
|
| 28 | - 'export:categories' |
|
| 26 | + 'export:accounts', |
|
| 27 | + 'export:groups', |
|
| 28 | + 'export:categories' |
|
| 29 | 29 | ]; |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -46,9 +46,9 @@ discard block |
||
| 46 | 46 | public function handle() |
| 47 | 47 | { |
| 48 | 48 | foreach ($this->commands as $cmd) { |
| 49 | - $this->call($cmd, [ |
|
| 49 | + $this->call($cmd, [ |
|
| 50 | 50 | '--ci' => $this->option('ci') |
| 51 | - ]); |
|
| 51 | + ]); |
|
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | } |
@@ -100,19 +100,19 @@ |
||
| 100 | 100 | |
| 101 | 101 | $flagCI = $this->option('ci'); |
| 102 | 102 | if ($flagCI === false) { |
| 103 | - $bar = $this->output->createProgressBar($count); |
|
| 103 | + $bar = $this->output->createProgressBar($count); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | foreach ($items as $item) { |
| 107 | 107 | $this->storage->prepend($filename, "{$item->value}"); |
| 108 | 108 | if ($flagCI === false) { |
| 109 | - $bar->advance(); |
|
| 109 | + $bar->advance(); |
|
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | if ($flagCI === false) { |
| 114 | - $bar->finish(); |
|
| 115 | - $this->info("\n"); |
|
| 114 | + $bar->finish(); |
|
| 115 | + $this->info("\n"); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | $url = $this->storage->path($filename); |
@@ -71,46 +71,46 @@ |
||
| 71 | 71 | * |
| 72 | 72 | * @return mixed |
| 73 | 73 | */ |
| 74 | - public function handle() |
|
| 75 | - { |
|
| 76 | - $groups = Group::get(); |
|
| 74 | + public function handle() |
|
| 75 | + { |
|
| 76 | + $groups = Group::get(); |
|
| 77 | 77 | |
| 78 | - if ($groups->isEmpty()) { |
|
| 79 | - $this->info("No groups to export"); |
|
| 80 | - return; |
|
| 81 | - } |
|
| 78 | + if ($groups->isEmpty()) { |
|
| 79 | + $this->info("No groups to export"); |
|
| 80 | + return; |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - foreach ($groups as $group){ |
|
| 84 | - $accounts = Account::where('status', Account::ACCOUNT_ENABLE) |
|
| 83 | + foreach ($groups as $group){ |
|
| 84 | + $accounts = Account::where('status', Account::ACCOUNT_ENABLE) |
|
| 85 | 85 | ->where('group_id', $group->id) |
| 86 | 86 | ->orderBy('netlogin', 'desc') |
| 87 | 87 | ->get(); |
| 88 | 88 | |
| 89 | - $count = count($accounts); |
|
| 90 | - |
|
| 91 | - $name = static::stringNormalise($group->name); |
|
| 92 | - $filename = "{$this->exportFolder}/{$name}{$this->exportFileExt}"; |
|
| 93 | - $this->storage->put($filename, ''); |
|
| 94 | - |
|
| 95 | - $flagCI = $this->option('ci'); |
|
| 96 | - if ($flagCI === false) { |
|
| 97 | - $bar = $this->output->createProgressBar($count); |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - foreach ($accounts as $account) { |
|
| 101 | - $this->storage->prepend($filename, "{$account->netlogin}:{$account->netpass}"); |
|
| 102 | - if ($flagCI === false) { |
|
| 103 | - $bar->advance(); |
|
| 104 | - } |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - if ($flagCI === false) { |
|
| 108 | - $bar->finish(); |
|
| 109 | - $this->info("\n"); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - $url = $this->storage->path($filename); |
|
| 113 | - $this->info("{$count} accounts '{$group->name}' exported into file '{$url}'"); |
|
| 114 | - } |
|
| 115 | - } |
|
| 89 | + $count = count($accounts); |
|
| 90 | + |
|
| 91 | + $name = static::stringNormalise($group->name); |
|
| 92 | + $filename = "{$this->exportFolder}/{$name}{$this->exportFileExt}"; |
|
| 93 | + $this->storage->put($filename, ''); |
|
| 94 | + |
|
| 95 | + $flagCI = $this->option('ci'); |
|
| 96 | + if ($flagCI === false) { |
|
| 97 | + $bar = $this->output->createProgressBar($count); |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + foreach ($accounts as $account) { |
|
| 101 | + $this->storage->prepend($filename, "{$account->netlogin}:{$account->netpass}"); |
|
| 102 | + if ($flagCI === false) { |
|
| 103 | + $bar->advance(); |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + if ($flagCI === false) { |
|
| 108 | + $bar->finish(); |
|
| 109 | + $this->info("\n"); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + $url = $this->storage->path($filename); |
|
| 113 | + $this->info("{$count} accounts '{$group->name}' exported into file '{$url}'"); |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | 116 | } |
@@ -80,7 +80,7 @@ |
||
| 80 | 80 | return; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - foreach ($groups as $group){ |
|
| 83 | + foreach ($groups as $group) { |
|
| 84 | 84 | $accounts = Account::where('status', Account::ACCOUNT_ENABLE) |
| 85 | 85 | ->where('group_id', $group->id) |
| 86 | 86 | ->orderBy('netlogin', 'desc') |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | public function handle() |
| 80 | 80 | { |
| 81 | 81 | $accounts = Account::where('status', Account::ACCOUNT_ENABLE) |
| 82 | - ->orderBy('netlogin', 'desc')->get(); |
|
| 82 | + ->orderBy('netlogin', 'desc')->get(); |
|
| 83 | 83 | |
| 84 | 84 | if ($accounts->isEmpty() && !$this->option('empty')) { |
| 85 | 85 | $this->info("No accounts to export"); |
@@ -93,19 +93,19 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | $flagCI = $this->option('ci'); |
| 95 | 95 | if ($flagCI === false) { |
| 96 | - $bar = $this->output->createProgressBar($count); |
|
| 96 | + $bar = $this->output->createProgressBar($count); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | foreach ($accounts as $account) { |
| 100 | 100 | $this->storage->prepend($filename, "{$account->netlogin}:{$account->netpass}"); |
| 101 | 101 | if ($flagCI === false) { |
| 102 | - $bar->advance(); |
|
| 102 | + $bar->advance(); |
|
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | if ($flagCI === false) { |
| 107 | - $bar->finish(); |
|
| 108 | - $this->info("\n"); |
|
| 107 | + $bar->finish(); |
|
| 108 | + $this->info("\n"); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | $url = $this->storage->path($filename); |
@@ -71,46 +71,46 @@ |
||
| 71 | 71 | * |
| 72 | 72 | * @return mixed |
| 73 | 73 | */ |
| 74 | - public function handle() |
|
| 75 | - { |
|
| 76 | - $categories = Category::get(); |
|
| 74 | + public function handle() |
|
| 75 | + { |
|
| 76 | + $categories = Category::get(); |
|
| 77 | 77 | |
| 78 | - if ($categories->isEmpty()) { |
|
| 79 | - $this->info("No categories to export"); |
|
| 80 | - return; |
|
| 81 | - } |
|
| 78 | + if ($categories->isEmpty()) { |
|
| 79 | + $this->info("No categories to export"); |
|
| 80 | + return; |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - foreach ($categories as $category){ |
|
| 84 | - $accounts = Account::where('status', Account::ACCOUNT_ENABLE) |
|
| 83 | + foreach ($categories as $category){ |
|
| 84 | + $accounts = Account::where('status', Account::ACCOUNT_ENABLE) |
|
| 85 | 85 | ->where('category_id', $category->id) |
| 86 | 86 | ->orderBy('netlogin', 'desc') |
| 87 | 87 | ->get(); |
| 88 | 88 | |
| 89 | - $count = count($accounts); |
|
| 90 | - |
|
| 91 | - $name = static::stringNormalise($category->name); |
|
| 92 | - $filename = "{$this->exportFolder}/{$name}{$this->exportFileExt}"; |
|
| 93 | - $this->storage->put($filename, ''); |
|
| 94 | - |
|
| 95 | - $flagCI = $this->option('ci'); |
|
| 96 | - if ($flagCI === false) { |
|
| 97 | - $bar = $this->output->createProgressBar($count); |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - foreach ($accounts as $account) { |
|
| 101 | - $this->storage->prepend($filename, "{$account->netlogin}:{$account->netpass}"); |
|
| 102 | - if ($flagCI === false) { |
|
| 103 | - $bar->advance(); |
|
| 104 | - } |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - if ($flagCI === false) { |
|
| 108 | - $bar->finish(); |
|
| 109 | - $this->info("\n"); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - $url = $this->storage->path($filename); |
|
| 113 | - $this->info("{$count} accounts '{$category->name}' exported into file '{$url}'"); |
|
| 114 | - } |
|
| 115 | - } |
|
| 89 | + $count = count($accounts); |
|
| 90 | + |
|
| 91 | + $name = static::stringNormalise($category->name); |
|
| 92 | + $filename = "{$this->exportFolder}/{$name}{$this->exportFileExt}"; |
|
| 93 | + $this->storage->put($filename, ''); |
|
| 94 | + |
|
| 95 | + $flagCI = $this->option('ci'); |
|
| 96 | + if ($flagCI === false) { |
|
| 97 | + $bar = $this->output->createProgressBar($count); |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + foreach ($accounts as $account) { |
|
| 101 | + $this->storage->prepend($filename, "{$account->netlogin}:{$account->netpass}"); |
|
| 102 | + if ($flagCI === false) { |
|
| 103 | + $bar->advance(); |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + if ($flagCI === false) { |
|
| 108 | + $bar->finish(); |
|
| 109 | + $this->info("\n"); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + $url = $this->storage->path($filename); |
|
| 113 | + $this->info("{$count} accounts '{$category->name}' exported into file '{$url}'"); |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | 116 | } |
@@ -80,7 +80,7 @@ |
||
| 80 | 80 | return; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - foreach ($categories as $category){ |
|
| 83 | + foreach ($categories as $category) { |
|
| 84 | 84 | $accounts = Account::where('status', Account::ACCOUNT_ENABLE) |
| 85 | 85 | ->where('category_id', $category->id) |
| 86 | 86 | ->orderBy('netlogin', 'desc') |
@@ -47,19 +47,19 @@ |
||
| 47 | 47 | |
| 48 | 48 | $flagCI = $this->option('ci'); |
| 49 | 49 | if ($flagCI === false) { |
| 50 | - $bar = $this->output->createProgressBar($count); |
|
| 50 | + $bar = $this->output->createProgressBar($count); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | foreach ($accounts as $account) { |
| 54 | 54 | $account->disable(); |
| 55 | 55 | if ($flagCI === false) { |
| 56 | - $bar->advance(); |
|
| 56 | + $bar->advance(); |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | if ($flagCI === false) { |
| 61 | - $bar->finish(); |
|
| 62 | - $this->info("\n"); |
|
| 61 | + $bar->finish(); |
|
| 62 | + $this->info("\n"); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | $this->info("{$count} accounts disabled"); |