CreateAuthThrottlesTable::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
use Arcanedev\LaravelAuth\Bases\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
6
/**
7
 * Class     CreatePermissionRoleTable
8
 *
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class CreateAuthThrottlesTable extends Migration
12
{
13
    /* -----------------------------------------------------------------
14
     |  Constructor
15
     | -----------------------------------------------------------------
16
     */
17
18
    /**
19
     * Make a migration instance.
20
     */
21
    public function __construct()
22
    {
23
        parent::__construct();
24
25
        $this->setTable(config('laravel-auth.throttles.table', 'throttles'));
26
    }
27
28
    /* -----------------------------------------------------------------
29
     |  Main Methods
30
     | -----------------------------------------------------------------
31
     */
32
33
    /**
34
     * Run the migrations.
35
     */
36
    public function up()
37
    {
38
        if ($this->isThrottlable())
39
            $this->createSchema(function (Blueprint $table) {
40
                $table->increments('id');
41
                $table->unsignedInteger('user_id')->nullable();
42
                $table->string('type');
43
                $table->string('ip')->nullable();
44
                $table->timestamps();
45
            });
46
    }
47
48
    /**
49
     * Reverse the migrations.
50
     */
51
    public function down()
52
    {
53
        if ($this->isThrottlable())
54
            parent::down();
55
    }
56
57
    /* -----------------------------------------------------------------
58
     |  Other Methods
59
     | -----------------------------------------------------------------
60
     */
61
62
    /**
63
     * Check if throttles is enabled.
64
     *
65
     * @return bool
66
     */
67
    private function isThrottlable()
68
    {
69
        return config('laravel-auth.throttles.enabled', false);
70
    }
71
}
72