MigrateCommand::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 3
c 2
b 0
f 0
dl 0
loc 7
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Orkhanahmadov\ContentMigrations\Console;
4
5
use Illuminate\Database\Console\Migrations\MigrateCommand as Command;
6
7
class MigrateCommand extends Command
8
{
9
    protected $signature = 'content-migrate';
10
11
    protected $description = 'Run the content migrations';
12
13
    public function handle()
14
    {
15
        $this->prepareDatabase();
16
17
        $this->migrator->setOutput($this->output)->run($this->getMigrationPaths());
18
19
        return 0;
20
    }
21
22
    protected function prepareDatabase()
23
    {
24
        if (! $this->migrator->repositoryExists()) {
25
            $this->call('content-migrate:install');
26
        }
27
    }
28
29
    protected function getMigrationPath()
30
    {
31
        return $this->laravel->databasePath() . DIRECTORY_SEPARATOR . 'content-migrations';
32
    }
33
}
34