@@ 10-70 (lines=61) @@ | ||
7 | use Consigliere\Components\Publishing\MigrationPublisher; |
|
8 | use Symfony\Component\Console\Input\InputArgument; |
|
9 | ||
10 | class PublishMigrationCommand extends ComponentCommand |
|
11 | { |
|
12 | /** |
|
13 | * The console command name. |
|
14 | * |
|
15 | * @var string |
|
16 | */ |
|
17 | protected $name = 'component:publish-migration'; |
|
18 | ||
19 | /** |
|
20 | * The console command description. |
|
21 | * |
|
22 | * @var string |
|
23 | */ |
|
24 | protected $description = "Publish a component's migrations to the application"; |
|
25 | ||
26 | /** |
|
27 | * Execute the console command. |
|
28 | * |
|
29 | * @return mixed |
|
30 | */ |
|
31 | public function fire() |
|
32 | { |
|
33 | if ($name = $this->argument('component')) { |
|
34 | $component = $this->laravel['components']->findOrFail($name); |
|
35 | ||
36 | $this->publish($component); |
|
37 | ||
38 | return; |
|
39 | } |
|
40 | ||
41 | foreach ($this->laravel['components']->enabled() as $component) { |
|
42 | $this->publish($component); |
|
43 | } |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * Publish migration for the specified component. |
|
48 | * |
|
49 | * @param \Consigliere\Components\Component $component |
|
50 | */ |
|
51 | public function publish($component) |
|
52 | { |
|
53 | with(new MigrationPublisher(new Migrator($component))) |
|
54 | ->setRepository($this->laravel['components']) |
|
55 | ->setConsole($this) |
|
56 | ->publish(); |
|
57 | } |
|
58 | ||
59 | /** |
|
60 | * Get the console command arguments. |
|
61 | * |
|
62 | * @return array |
|
63 | */ |
|
64 | protected function getArguments() |
|
65 | { |
|
66 | return [ |
|
67 | ['component', InputArgument::OPTIONAL, 'The name of component being used.'], |
|
68 | ]; |
|
69 | } |
|
70 | } |
|
71 |
@@ 10-70 (lines=61) @@ | ||
7 | use Consigliere\Components\Publishing\SeedPublisher; |
|
8 | use Symfony\Component\Console\Input\InputArgument; |
|
9 | ||
10 | class PublishSeedCommand extends ComponentCommand |
|
11 | { |
|
12 | /** |
|
13 | * The console command name. |
|
14 | * |
|
15 | * @var string |
|
16 | */ |
|
17 | protected $name = 'component:publish-seed'; |
|
18 | ||
19 | /** |
|
20 | * The console command description. |
|
21 | * |
|
22 | * @var string |
|
23 | */ |
|
24 | protected $description = "Publish a component's seeds to the application"; |
|
25 | ||
26 | /** |
|
27 | * Execute the console command. |
|
28 | * |
|
29 | * @return mixed |
|
30 | */ |
|
31 | public function fire() |
|
32 | { |
|
33 | if ($name = $this->argument('component')) { |
|
34 | $component = $this->laravel['components']->findOrFail($name); |
|
35 | ||
36 | $this->publish($component); |
|
37 | ||
38 | return; |
|
39 | } |
|
40 | ||
41 | foreach ($this->laravel['components']->enabled() as $component) { |
|
42 | $this->publish($component); |
|
43 | } |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * Publish migration for the specified component. |
|
48 | * |
|
49 | * @param \Consigliere\Components\Component $component |
|
50 | */ |
|
51 | public function publish($component) |
|
52 | { |
|
53 | with(new SeedPublisher(new Seeder($component))) |
|
54 | ->setRepository($this->laravel['components']) |
|
55 | ->setConsole($this) |
|
56 | ->publish(); |
|
57 | } |
|
58 | ||
59 | /** |
|
60 | * Get the console command arguments. |
|
61 | * |
|
62 | * @return array |
|
63 | */ |
|
64 | protected function getArguments() |
|
65 | { |
|
66 | return [ |
|
67 | ['component', InputArgument::OPTIONAL, 'The name of component being used.'], |
|
68 | ]; |
|
69 | } |
|
70 | } |
|
71 |