This repository was archived by the owner on Feb 18, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathMigrateCommand.php
65 lines (57 loc) · 1.8 KB
/
MigrateCommand.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
namespace DarkGhostHunter\Laraconfig\Console\Commands;
use DarkGhostHunter\Laraconfig\Migrator\Data;
use DarkGhostHunter\Laraconfig\Migrator\Migrator;
use Illuminate\Console\Command;
use Illuminate\Console\OutputStyle;
use RuntimeException;
use Symfony\Component\Console\Input\InputInterface;
/**
* @internal
*/
class MigrateCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'settings:migrate
{--refresh : Wipes clean the settings table and metadata table.}
{--flush-cache : Flushes the cache used by Laraconfig, if enabled.}
{--force : Skips confirmation prompt on production.}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Synchronizes and updates the settings from the database';
/**
* MigrateCommand constructor.
*
* @param \DarkGhostHunter\Laraconfig\Migrator\Migrator $migrator
* @param \DarkGhostHunter\Laraconfig\Migrator\Data $data
*/
public function __construct(protected Migrator $migrator, protected Data $data)
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle(): int
{
// We will use the Input interface to use the same instance.
$this->getLaravel()->instance(InputInterface::class, $this->input);
$this->getLaravel()->instance(OutputStyle::class, $this->output);
try {
$this->migrator->send($this->data)->thenReturn();
} catch (RuntimeException $exception) {
$this->error($exception->getMessage());
return 1;
}
return 0;
}
}