Skip to content

Commit f655f5d

Browse files
author
Andrey Helldar
authored
Merge pull request #42 from TheDragonCode/2.x
Removed timestamp suffix when generating anonymous actions
2 parents 28dcad9 + c826d7b commit f655f5d

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,33 @@ If a git repository is found in the main folder, then the name of the current ac
9191
```bash
9292
php artisan make:migration:action
9393

94+
### Before Laravel 8.37
9495
# 2022_01_28_184116_main_1643384476.php
9596
# 2022_01_28_184117_main_1643384477.php
9697
# 2022_01_28_184118_crm_2345_1643384478.php
9798
# 2022_01_28_184119_crm_2345_1643384479.php
99+
100+
### Laravel 8.37 or higher
101+
# 2022_01_28_184116_main.php
102+
# 2022_01_28_184117_main.php
103+
# 2022_01_28_184118_crm_2345.php
104+
# 2022_01_28_184119_crm_2345.php
98105
```
99106

100107
If the git repository is not found, then the default prefix will be used:
101108

102109
```bash
103110
php artisan make:migration:action
104111

112+
### Before Laravel 8.37
105113
# 2022_01_28_184116_auto_1643384476.php
106114
# 2022_01_28_184117_auto_1643384477.php
107115
# 2022_01_28_184118_auto_1643384478.php
116+
117+
### Laravel 8.37 or higher
118+
# 2022_01_28_184116_auto.php
119+
# 2022_01_28_184117_auto.php
120+
# 2022_01_28_184118_auto.php
108121
```
109122

110123
If you are using Laravel prior to version [8.37](https://github.com/laravel/framework/releases/tag/v8.37.0), then to ensure backward compatibility, if the current git repository

src/Concerns/Argumentable.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
/** @mixin \Illuminate\Console\Command */
88
trait Argumentable
99
{
10+
use Anonymous;
11+
1012
protected $auto_prefix = 'auto';
1113

1214
protected $branch_prefix = 'branch';
@@ -17,6 +19,15 @@ protected function argumentName(): string
1719
return trim($name);
1820
}
1921

22+
return $this->makeName();
23+
}
24+
25+
protected function makeName(): string
26+
{
27+
if ($this->allowAnonymous()) {
28+
return $this->getAutoPrefix();
29+
}
30+
2031
return $this->getAutoPrefix() . '_' . time();
2132
}
2233

@@ -31,7 +42,7 @@ protected function getGitBranchName(): ?string
3142

3243
preg_match('/^\d.*$/', $name, $output);
3344

34-
if (! empty($output)) {
45+
if (! empty($output) && $this->disallowAnonymous()) {
3546
return $this->branch_prefix . '_' . $name;
3647
}
3748

tests/Commands/MakeTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ public function testMakingFiles()
2929

3030
public function testAutoName()
3131
{
32-
$filename = date('Y_m_d_His') . '_auto_' . time() . '.php';
32+
$filename = $this->allowAnonymous()
33+
? date('Y_m_d_His') . '_auto.php'
34+
: date('Y_m_d_His') . '_auto_' . time() . '.php';
3335

3436
$path = database_path('actions/' . $filename);
3537

0 commit comments

Comments
 (0)