Completed
Push — develop ( 7bb86a...82de8f )
by Wisoot
02:16
created

2014_10_12_200000_create_user_tokens_table.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
use Illuminate\Database\Schema\Blueprint;
4
use Illuminate\Database\Migrations\Migration;
5
6
class CreateUserTokensTable 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...
7
{
8
    /**
9
     * @var        string    $table    Table name.
10
     */
11
    protected $table;
12
13
    /**
14
     * @var        string    $foreignKey    Column name for foreign keys.
15
     */
16
    protected $foreignKey;
17
18
    /**
19
     * Initialise the migration.
20
     *
21
     * @return    void
22
     */
23
    public function __construct()
24
    {
25
        $this->table = $this->config('token_table');
26
27
        $this->foreignKey = $this->config('user_foreign_key');
28
    }
29
30
    /**
31
     * Run the migrations.
32
     *
33
     * @return void
34
     */
35
    public function up()
36
    {
37
        Schema::create($this->table, function (Blueprint $table) {
38
            $table->increments('id');
39
            $table->integer($this->foreignKey)->unsigned();
40
            $table->string('token')->index();
41
            $table->timestamps();
42
43
            $table->foreign($this->foreignKey)->references('id')->on('users');
44
        });
45
    }
46
47
    /**
48
     * Reverse the migrations.
49
     *
50
     * @return void
51
     */
52
    public function down()
53
    {
54
        Schema::drop($this->table);
55
    }
56
57
    /**
58
     * Retrieve a setting from the package configuration.
59
     *
60
     * @param    string    $key
61
     * @param    mixed    $default
62
     * @return    mixed
63
     */
64
    private function config($key, $default = null)
65
    {
66
        return config("jwt_guard.{$key}", $default);
67
    }
68
}
69