3
3
namespace Nanvaie \DatabaseRepository \Commands ;
4
4
5
5
use Illuminate \Console \Command ;
6
+ use Nanvaie \DatabaseRepository \CustomMySqlQueries ;
7
+ use phpDocumentor \Reflection \PseudoTypes \NonEmptyLowercaseString ;
6
8
7
9
class MakeAll extends Command
8
10
{
11
+ use CustomMySqlQueries;
12
+
9
13
/**
10
14
* The name and signature of the console command.
11
15
*
12
16
* @var string
13
17
*/
14
- protected $ signature = 'repository:make-all {table_names*}
18
+ protected $ signature = 'repository:make-all
19
+ {--table_names= : Table names, separate names with comma}
15
20
{--k|foreign-keys : Detect foreign keys}
16
21
{--d|delete : Delete resource}
17
22
{--f|force : Override/Delete existing classes}
18
- {--g|add-to-git : Add created file to git repository} ' ;
23
+ {--g|add-to-git : Add created file to git repository}
24
+ {--a|all-tables : Add created file to git repository} ' ;
19
25
20
26
/**
21
27
* The console command description.
@@ -29,12 +35,20 @@ class MakeAll extends Command
29
35
*/
30
36
public function handle ()
31
37
{
32
- $ tableNames = $ this ->argument ('table_names ' );
33
38
$ force = $ this ->option ('force ' );
34
39
$ delete = $ this ->option ('delete ' );
35
40
$ detectForeignKeys = $ this ->option ('foreign-keys ' );
36
41
$ addToGit = $ this ->option ('add-to-git ' );
37
42
43
+ if ($ this ->option ('all-tables ' )) {
44
+ $ tableNames = $ this ->getAllTableNames ()->pluck ('TABLE_NAME ' );
45
+ } else if ($ this ->option ('table_names ' )) {
46
+ $ tableNames = explode (', ' , $ this ->option ('table_names ' ));
47
+ } else {
48
+ $ this ->alert ("Please choose one of two options '--all-tables' or '--table_names=' " );
49
+ die;
50
+ }
51
+
38
52
foreach ($ tableNames as $ _tableName ) {
39
53
$ arguments = [
40
54
'table_name ' => $ _tableName ,
0 commit comments