Skip to content

Commit 6a50665

Browse files
author
Andrey Helldar
committed
Changed information output from migrations to actions
1 parent 474e35d commit 6a50665

File tree

15 files changed

+132
-10
lines changed

15 files changed

+132
-10
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"php": "^7.3|^8.0",
1919
"illuminate/console": "^6.0|^7.0|^8.0",
2020
"illuminate/database": "^6.0|^7.0|^8.0",
21-
"illuminate/support": "^6.0|^7.0|^8.0"
21+
"illuminate/support": "^6.0|^7.0|^8.0",
22+
"symfony/console": "^4.3.4|^5.0"
2223
},
2324
"require-dev": {
2425
"mockery/mockery": "^1.3.1",

src/Console/Install.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
use Helldar\LaravelActions\Constants\Names;
66
use Helldar\LaravelActions\Traits\Database;
7+
use Helldar\LaravelActions\Traits\Infoable;
78
use Illuminate\Database\Console\Migrations\InstallCommand as BaseCommand;
89

910
final class Install extends BaseCommand
1011
{
1112
use Database;
13+
use Infoable;
1214

1315
/**
1416
* The console command name.

src/Console/Make.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Helldar\LaravelActions\Constants\Names;
66
use Helldar\LaravelActions\Traits\Database;
7+
use Helldar\LaravelActions\Traits\Infoable;
78
use Illuminate\Database\Console\Migrations\BaseCommand;
89
use Illuminate\Database\Migrations\MigrationCreator;
910
use Illuminate\Support\Composer;
@@ -12,6 +13,7 @@
1213
final class Make extends BaseCommand
1314
{
1415
use Database;
16+
use Infoable;
1517

1618
/**
1719
* The console command name.
@@ -86,6 +88,6 @@ protected function writeMigration(string $name)
8688

8789
$path = pathinfo($file, PATHINFO_FILENAME);
8890

89-
$this->line("<info>Created Migration:</info> {$path}");
91+
$this->line("<info>Created Action:</info> {$path}");
9092
}
9193
}

src/Console/Migrate.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55
use Helldar\LaravelActions\Constants\Names;
66
use Helldar\LaravelActions\Traits\Database;
7+
use Helldar\LaravelActions\Traits\Infoable;
78
use Helldar\LaravelActions\Traits\Optionable;
89
use Illuminate\Database\Console\Migrations\MigrateCommand as BaseCommand;
910

1011
final class Migrate extends BaseCommand
1112
{
1213
use Database;
14+
use Infoable;
1315
use Optionable;
1416

1517
/**
@@ -20,7 +22,7 @@ final class Migrate extends BaseCommand
2022
protected $signature = Names::MIGRATE
2123
. ' {--database= : The database connection to use}'
2224
. ' {--force : Force the operation to run when in production}'
23-
. ' {--step : Force the migrations to be run so they can be rolled back individually}';
25+
. ' {--step : Force the actions to be run so they can be rolled back individually}';
2426

2527
/**
2628
* The console command description.

src/Console/Refresh.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Helldar\LaravelActions\Constants\Names;
66
use Helldar\LaravelActions\Traits\Database;
7+
use Helldar\LaravelActions\Traits\Infoable;
78
use Helldar\LaravelActions\Traits\Optionable;
89
use Illuminate\Console\Command as BaseCommand;
910
use Illuminate\Console\ConfirmableTrait;
@@ -15,6 +16,7 @@ final class Refresh extends BaseCommand
1516
{
1617
use ConfirmableTrait;
1718
use Database;
19+
use Infoable;
1820
use Optionable;
1921

2022
/**

src/Console/Reset.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Helldar\LaravelActions\Constants\Names;
66
use Helldar\LaravelActions\Traits\Database;
7+
use Helldar\LaravelActions\Traits\Infoable;
78
use Helldar\LaravelActions\Traits\Optionable;
89
use Illuminate\Console\ConfirmableTrait;
910
use Illuminate\Database\Console\Migrations\BaseCommand;
@@ -14,6 +15,7 @@ final class Reset extends BaseCommand
1415
{
1516
use ConfirmableTrait;
1617
use Database;
18+
use Infoable;
1719
use Optionable;
1820

1921
/**
@@ -49,6 +51,11 @@ public function __construct(Migrator $migrator)
4951
$this->migrator = $migrator;
5052
}
5153

54+
/**
55+
* Execute the console command.
56+
*
57+
* @return int|void
58+
*/
5259
public function handle()
5360
{
5461
if (! $this->confirmToProceed()) {
@@ -57,12 +64,16 @@ public function handle()
5764

5865
return $this->migrator->usingConnection($this->optionDatabase(), function () {
5966
if (! $this->migrator->repositoryExists()) {
60-
return $this->comment('Migration table not found.');
67+
$this->comment('Actions table not found.');
68+
69+
return 1;
6170
}
6271

6372
$this->migrator->setOutput($this->output)->reset(
6473
$this->getMigrationPaths()
6574
);
75+
76+
return 0;
6677
});
6778
}
6879

src/Console/Rollback.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44

55
use Helldar\LaravelActions\Constants\Names;
66
use Helldar\LaravelActions\Traits\Database;
7+
use Helldar\LaravelActions\Traits\Infoable;
78
use Helldar\LaravelActions\Traits\Optionable;
89
use Illuminate\Database\Console\Migrations\RollbackCommand;
910
use Symfony\Component\Console\Input\InputOption;
1011

1112
final class Rollback extends RollbackCommand
1213
{
1314
use Database;
15+
use Infoable;
1416
use Optionable;
1517

1618
/**
@@ -41,9 +43,7 @@ public function handle()
4143
$this->migrator->usingConnection($this->optionDatabase(), function () {
4244
$this->migrator->setOutput($this->output)->rollback(
4345
$this->getMigrationPaths(),
44-
[
45-
'step' => $this->optionStep(),
46-
]
46+
['step' => $this->optionStep()]
4747
);
4848
});
4949

@@ -62,7 +62,7 @@ protected function getOptions()
6262

6363
['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production'],
6464

65-
['step', null, InputOption::VALUE_OPTIONAL, 'The number of migrations to be reverted'],
65+
['step', null, InputOption::VALUE_OPTIONAL, 'The number of actions to be reverted'],
6666
];
6767
}
6868
}

src/Console/Status.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
use Helldar\LaravelActions\Constants\Names;
66
use Helldar\LaravelActions\Traits\Database;
7+
use Helldar\LaravelActions\Traits\Infoable;
78
use Illuminate\Database\Console\Migrations\StatusCommand as BaseCommand;
89

910
final class Status extends BaseCommand
1011
{
1112
use Database;
13+
use Infoable;
1214

1315
/**
1416
* The console command name.

src/Facades/Information.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace Helldar\LaravelActions\Facades;
4+
5+
use Helldar\LaravelActions\Support\Information as Support;
6+
use Illuminate\Support\Facades\Facade;
7+
8+
/**
9+
* @method static string replace(string $value)
10+
*/
11+
final class Information extends Facade
12+
{
13+
protected static function getFacadeAccessor()
14+
{
15+
return Support::class;
16+
}
17+
}

src/Support/Information.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Helldar\LaravelActions\Support;
4+
5+
use Illuminate\Support\Str;
6+
7+
final class Information
8+
{
9+
protected $available = [
10+
'Migrating:' => 'Running:',
11+
'Migrated:' => 'Done:',
12+
'Nothing to migrate' => 'Nothing to do',
13+
'Migration table created successfully' => 'Action table created successfully',
14+
'Migration table not found' => 'Actions table not found',
15+
'No migrations found' => 'No actions found',
16+
'Migration not found' => 'Action not found',
17+
];
18+
19+
public function replace(string $value): string
20+
{
21+
foreach ($this->available as $search => $replace) {
22+
if (Str::contains($value, $search)) {
23+
return str_replace($search, $replace, $value);
24+
}
25+
}
26+
27+
return $value;
28+
}
29+
}

0 commit comments

Comments
 (0)