Passed
Push — master ( c12bfb...46822b )
by Ferry
03:30
created

Generate::generate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php namespace crocodicstudio\crudbooster\commands;
2
3
use App;
4
use Cache;
5
use crocodicstudio\crudbooster\helpers\ModuleGenerator;
6
use Illuminate\Support\Facades\DB;
7
use Illuminate\Console\Command;
8
use Symfony\Component\Process\Process;
9
10
class Generate extends Command
11
{
12
    /**
13
     * The console command name.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'crudbooster:make {--module=ALL : The table that want to generate the module}';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'CRUDBooster Make a Module';
25
26
    /**
27
     * Execute the console command.
28
     *
29
     * @return mixed
30
     */
31
    public function handle()
32
    {
33
        $this->info($this->description);
34
        $option = $this->option("module");
35
        if($option == "ALL") {
36
            $tables = DB::connection()->getDoctrineSchemaManager()->listTableNames();
37
            foreach($tables as $table) {
38
                $this->generate($table);
39
            }
40
        }
41
    }
42
43
    private function generate($table) {
44
        (new ModuleGenerator($table))->make();
45
        $this->info("New module from table ".$table." has been created!");
46
    }
47
}
48