33namespace Nanvaie \DatabaseRepository \Commands ;
44
55use Illuminate \Console \Command ;
6+ use Nanvaie \DatabaseRepository \CustomMySqlQueries ;
7+ use phpDocumentor \Reflection \PseudoTypes \NonEmptyLowercaseString ;
68
79class MakeAll extends Command
810{
11+ use CustomMySqlQueries;
12+
913 /**
1014 * The name and signature of the console command.
1115 *
1216 * @var string
1317 */
14- protected $ signature = 'repository:make-all {table_names*}
18+ protected $ signature = 'repository:make-all
19+ {--table_names= : Table names, separate names with comma}
1520 {--k|foreign-keys : Detect foreign keys}
1621 {--d|delete : Delete resource}
1722 {--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} ' ;
1925
2026 /**
2127 * The console command description.
@@ -29,12 +35,20 @@ class MakeAll extends Command
2935 */
3036 public function handle ()
3137 {
32- $ tableNames = $ this ->argument ('table_names ' );
3338 $ force = $ this ->option ('force ' );
3439 $ delete = $ this ->option ('delete ' );
3540 $ detectForeignKeys = $ this ->option ('foreign-keys ' );
3641 $ addToGit = $ this ->option ('add-to-git ' );
3742
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+
3852 foreach ($ tableNames as $ _tableName ) {
3953 $ arguments = [
4054 'table_name ' => $ _tableName ,
0 commit comments