MigrationsController   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 4
dl 0
loc 58
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 8 1
A rollback() 0 8 1
A seed() 0 8 1
A refresh() 0 10 1
A fresh() 0 8 1
A deleteLast() 0 8 1
1
<?php
2
3
namespace Mtolhuys\LaravelSchematics\Http\Controllers;
4
5
use Illuminate\Support\Facades\Artisan;
6
use Illuminate\Routing\Controller;
7
use Illuminate\Support\Facades\Cache;
8
use Mtolhuys\LaravelSchematics\Actions\Migration\DeleteLastMigrationAction;
9
10
class MigrationsController extends Controller
11
{
12
    public function run()
13
    {
14
        Artisan::call('migrate');
15
16
        Cache::forget('schematics');
17
18
        return Artisan::output();
19
    }
20
21
    public function rollback()
22
    {
23
        Artisan::call('migrate:rollback');
24
25
        Cache::forget('schematics');
26
27
        return Artisan::output();
28
    }
29
30
    public function seed()
31
    {
32
        Artisan::call('db:seed');
33
34
        Cache::forget('schematics');
35
36
        return Artisan::output();
37
    }
38
39
    public function refresh()
40
    {
41
        Artisan::call('migrate:refresh', [
42
            '--force' => true,
43
        ]);
44
45
        Cache::forget('schematics');
46
47
        return Artisan::output();
48
    }
49
50
    public function fresh()
51
    {
52
        Artisan::call('migrate:fresh');
53
54
        Cache::forget('schematics');
55
56
        return Artisan::output();
57
    }
58
59
    public function deleteLast()
60
    {
61
        (new DeleteLastMigrationAction())->execute();
62
63
        Cache::forget('schematics');
64
65
        return response('Last migration removed', 200);
66
    }
67
}
68