MigrationCommand   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 5
c 1
b 1
f 0
dl 0
loc 25
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A fire() 0 4 1
1
<?php
2
3
namespace Djoudi\LaravelH5p\Commands;
4
5
use Illuminate\Console\Command;
6
7
class MigrationCommand extends Command
8
{
9
    /**
10
     * The console command name.
11
     *
12
     * @var string
13
     */
14
    protected $name = 'laravel-h5p:migration';
15
16
    /**
17
     * The console command description.
18
     *
19
     * @var string
20
     */
21
    protected $description = 'Creates a migration following the Laravel-H5p specifications.';
22
23
    /**
24
     * Execute the console command.
25
     *
26
     * @return void
27
     */
28
    public function fire()
29
    {
30
        $this->line('');
31
        $this->info('Laravel-H5p Creating migration...');
32
33
//        $this->laravel->view->addNamespace('entrust', substr(__DIR__, 0, -8) . 'views');
34
        //
35
        //        $rolesTable = Config::get('entrust.roles_table');
36
        //        $roleUserTable = Config::get('entrust.role_user_table');
37
        //        $permissionsTable = Config::get('entrust.permissions_table');
38
        //        $permissionRoleTable = Config::get('entrust.permission_role_table');
39
        //
40
        //        $this->line('');
41
        //        $this->info("Tables: $rolesTable, $roleUserTable, $permissionsTable, $permissionRoleTable");
42
        //
43
        //        $message = "A migration that creates '$rolesTable', '$roleUserTable', '$permissionsTable', '$permissionRoleTable'" .
44
        //                " tables will be created in database/migrations directory";
45
        //
46
        //        $this->comment($message);
47
        //        $this->line('');
48
        //
49
        //        if ($this->confirm("Proceed with the migration creation? [Yes|no]", "Yes")) {
50
        //
51
        //            $this->line('');
52
        //
53
        //            $this->info("Creating migration...");
54
        //            if ($this->createMigration($rolesTable, $roleUserTable, $permissionsTable, $permissionRoleTable)) {
55
        //
56
        //                $this->info("Migration successfully created!");
57
        //            } else {
58
        //                $this->error(
59
        //                        "Couldn't create migration.\n Check the write permissions" .
60
        //                        " within the database/migrations directory."
61
        //                );
62
        //            }
63
        //
64
        //            $this->line('');
65
        //        }
66
    }
67
68
    /*
69
     * Create the migration.
70
     *
71
     * @param string $name
72
     *
73
     * @return bool
74
     */
75
//    protected function createMigration($rolesTable, $roleUserTable, $permissionsTable, $permissionRoleTable) {
76
    //        $migrationFile = base_path("/database/migrations") . "/" . date('Y_m_d_His') . "_entrust_setup_tables.php";
77
    //
78
    //        $userModel = Config::get('auth.providers.users.model');
79
    //        $userModel = new $userModel;
80
    //        $userKeyName = $userModel->getKeyName();
81
    //        $usersTable = $userModel->getTable();
82
    //
83
    //        $data = compact('rolesTable', 'roleUserTable', 'permissionsTable', 'permissionRoleTable', 'usersTable', 'userKeyName');
84
    //
85
    //        $output = $this->laravel->view->make('entrust::generators.migration')->with($data)->render();
86
    //
87
    //        if (!file_exists($migrationFile) && $fs = fopen($migrationFile, 'x')) {
88
    //            fwrite($fs, $output);
89
    //            fclose($fs);
90
    //            return true;
91
    //        }
92
    //
93
    //        return false;
94
    //    }
95
}
96