|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ghaskell\Scaffold\Console\Commands; |
|
4
|
|
|
|
|
5
|
|
|
use Ghaskell\Scaffold\Facades\Vibro; |
|
6
|
|
|
use Ghaskell\Scaffold\Scaffold; |
|
7
|
|
|
use Illuminate\Console\Command; |
|
8
|
|
|
use Symfony\Component\Finder\Finder; |
|
9
|
|
|
use Illuminate\Filesystem\Filesystem; |
|
10
|
|
|
|
|
11
|
|
|
//use Illuminate\Console\GeneratorCommand; |
|
12
|
|
|
|
|
13
|
|
|
class ScaffoldGenerate extends Command |
|
14
|
|
|
{ |
|
15
|
|
|
protected $migrationFiles; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* The filesystem instance. |
|
19
|
|
|
* |
|
20
|
|
|
* @var \Illuminate\Filesystem\Filesystem |
|
21
|
|
|
*/ |
|
22
|
|
|
protected $files; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* The filesystem instance. |
|
26
|
|
|
* |
|
27
|
|
|
* @var \Illuminate\Filesystem\Filesystem |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $migrations; |
|
30
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* The name and signature of the console command. |
|
34
|
|
|
* |
|
35
|
|
|
* @var string |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $signature = 'scaffold:generate'; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* The console command description. |
|
41
|
|
|
* |
|
42
|
|
|
* @var string |
|
43
|
|
|
*/ |
|
44
|
|
|
protected $description = 'Generate from migration'; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Create a new command instance. |
|
48
|
|
|
* |
|
49
|
|
|
*/ |
|
50
|
|
|
public function __construct(Filesystem $filesystem) |
|
51
|
|
|
{ |
|
52
|
|
|
parent::__construct(); |
|
53
|
|
|
$this->files = $filesystem; |
|
54
|
|
|
$this->migrations = []; |
|
|
|
|
|
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Execute the console command. |
|
59
|
|
|
* |
|
60
|
|
|
* @return void |
|
61
|
|
|
*/ |
|
62
|
|
|
public function handle() |
|
63
|
|
|
{ |
|
64
|
|
|
$this->getMigrations(); |
|
65
|
|
|
foreach ($this->migrations as $migration) { |
|
66
|
|
|
$this->line("------------------------------------------------------------------------------------------------------------------"); |
|
67
|
|
|
$this->info("Generating for {$migration}"); |
|
68
|
|
|
$this->line("------------------------------------------------------------------------------------------------------------------"); |
|
69
|
|
|
$files = config('scaffold.files'); |
|
70
|
|
|
$scaffold = Scaffold::make($migration); |
|
71
|
|
|
foreach($files as $key => $file) { |
|
72
|
|
|
$scaffold->generate($key); |
|
73
|
|
|
} |
|
74
|
|
|
$scaffold->addRoutes(); |
|
75
|
|
|
|
|
76
|
|
|
foreach($scaffold->created as $created) { |
|
77
|
|
|
$this->info("File '$created' generated."); |
|
78
|
|
|
} |
|
79
|
|
|
foreach($scaffold->messages as $message) { |
|
80
|
|
|
$this->comment($message); |
|
81
|
|
|
} |
|
82
|
|
|
$this->line("------------------------------------------------------------------------------------------------------------------"); |
|
83
|
|
|
|
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
protected function getMigrations() |
|
87
|
|
|
{ |
|
88
|
|
|
//Remove built in files |
|
89
|
|
|
$finder = new Finder(); |
|
90
|
|
|
$files = $finder->files() |
|
91
|
|
|
->name('*table.php') |
|
92
|
|
|
->notName('2014*') |
|
93
|
|
|
->in(database_path() . '/migrations'); |
|
94
|
|
|
|
|
95
|
|
|
foreach ($files as $file) { |
|
96
|
|
|
$this->migrations[] = $file->getRealPath() ; |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..