CreateTwoStepAuthTable   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
dl 0
loc 41
c 1
b 0
f 0
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A down() 0 7 1
A up() 0 18 2
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Support\Facades\Schema;
6
use jeremykenedy\laravel2step\App\Models\TwoStepAuth;
7
8
class CreateTwoStepAuthTable extends Migration
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
9
{
10
    /**
11
     * Run the migrations.
12
     *
13
     * @return void
14
     */
15
    public function up()
16
    {
17
        $twoStepAuth = new TwoStepAuth();
18
        $connection = $twoStepAuth->getConnectionName();
19
        $table = $twoStepAuth->getTableName();
20
        $tableCheck = Schema::connection($connection)->hasTable($table);
21
22
        if (! $tableCheck) {
23
            Schema::connection($connection)->create($table, function (Blueprint $table) {
24
                $table->increments('id');
25
                $table->unsignedBigInteger('userId')->unsigned()->index();
26
                $table->foreign('userId')->references('id')->on('users')->onDelete('cascade');
27
                $table->string('authCode')->nullable();
28
                $table->integer('authCount');
29
                $table->boolean('authStatus')->default(false);
30
                $table->dateTime('authDate')->nullable();
31
                $table->dateTime('requestDate')->nullable();
32
                $table->timestamps();
33
            });
34
        }
35
    }
36
37
    /**
38
     * Reverse the migrations.
39
     *
40
     * @return void
41
     */
42
    public function down()
43
    {
44
        $twoStepAuth = new TwoStepAuth();
45
        $connection = $twoStepAuth->getConnectionName();
46
        $table = $twoStepAuth->getTableName();
47
48
        Schema::connection($connection)->dropIfExists($table);
49
    }
50
}
51