1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace LaravelFreelancerNL\Aranguent\Providers; |
4
|
|
|
|
5
|
|
|
use LaravelFreelancerNL\Aranguent\Console\ModelAranguentCommand; |
6
|
|
|
use LaravelFreelancerNL\Aranguent\Migrations\MigrationCreator; |
7
|
|
|
use LaravelFreelancerNL\Aranguent\Console\Migrations\MigrateMakeCommand; |
8
|
|
|
use LaravelFreelancerNL\Aranguent\Migrations\DatabaseMigrationRepository; |
9
|
|
|
use Illuminate\Database\MigrationServiceProvider as IlluminateMigrationServiceProvider; |
10
|
|
|
use LaravelFreelancerNL\Aranguent\Console\Migrations\AranguentConvertMigrationsCommand; |
11
|
|
|
|
12
|
|
|
class CommandServiceProvider extends IlluminateMigrationServiceProvider |
13
|
|
|
{ |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* {@inheritdoc} |
17
|
|
|
*/ |
18
|
|
|
protected $defer = true; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* {@inheritdoc} |
22
|
|
|
*/ |
23
|
|
|
public function boot() |
24
|
|
|
{ |
25
|
|
|
if ($this->app->runningInConsole()) { |
26
|
|
|
$this->commands([ |
27
|
|
|
MigrateMakeCommand::class, |
28
|
|
|
ModelAranguentCommand::class |
29
|
|
|
]); |
30
|
|
|
} |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* {@inheritdoc} |
35
|
|
|
*/ |
36
|
|
|
public function register() |
37
|
|
|
{ |
38
|
|
|
$this->registerRepository(); |
39
|
|
|
|
40
|
|
|
$this->registerMigrator(); |
41
|
|
|
|
42
|
|
|
$this->registerCreator(); |
43
|
|
|
|
44
|
|
|
$commands = array_merge($this->commands, |
45
|
|
|
[ |
46
|
|
|
'MigrateMake' => 'command.migrate.make', |
47
|
|
|
'AranguentConvertMigrations' => 'command.aranguent.convert-migrations', |
48
|
|
|
'MakeModel' => 'command.model.make', |
49
|
|
|
] |
50
|
|
|
); |
51
|
|
|
$this->registerCommands($commands); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* {@inheritdoc} |
56
|
|
|
*/ |
57
|
|
|
protected function registerRepository() |
58
|
|
|
{ |
59
|
|
|
$this->app->singleton('migration.repository', function ($app) { |
60
|
|
|
$collection = $app['config']['database.migrations']; |
61
|
|
|
|
62
|
|
|
return new DatabaseMigrationRepository($app['db'], $collection); |
63
|
|
|
}); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
protected function registerCreator() |
67
|
|
|
{ |
68
|
|
|
$this->app->singleton('migration.creator', function ($app) { |
69
|
|
|
return new MigrationCreator($app['files']); |
70
|
|
|
}); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Register the command. |
75
|
|
|
* |
76
|
|
|
* @return void |
77
|
|
|
*/ |
78
|
|
|
protected function registerMigrateMakeCommand() |
79
|
|
|
{ |
80
|
|
|
$this->app->singleton('command.migrate.make', function ($app) { |
81
|
|
|
$creator = $app['migration.creator']; |
82
|
|
|
|
83
|
|
|
$composer = $app['composer']; |
84
|
|
|
|
85
|
|
|
return new MigrateMakeCommand($creator, $composer); |
86
|
|
|
}); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
protected function registerAranguentConvertMigrationsCommand() |
90
|
|
|
{ |
91
|
|
|
$this->app->singleton('command.aranguent.convert-migrations', function ($app) { |
92
|
|
|
return new AranguentConvertMigrationsCommand($app['migrator']); |
93
|
|
|
}); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
protected function registerMakeModelCommand() |
97
|
|
|
{ |
98
|
|
|
$this->app->singleton('command.model.make', function ($app) { |
99
|
|
|
return new ModelAranguentCommand($app['files']); |
100
|
|
|
}); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function provides() |
104
|
|
|
{ |
105
|
|
|
return [ |
106
|
|
|
'migrator', |
107
|
|
|
'migration.creator', |
108
|
|
|
'migration.repository', |
109
|
|
|
'command.aranguent.convert-migrations', |
110
|
|
|
'command.migrate.make', |
111
|
|
|
'command.model.make', |
112
|
|
|
]; |
113
|
|
|
} |
114
|
|
|
} |
115
|
|
|
|