Completed
Push — master ( d1abb9...2c5b6e )
by Ricardo
02:02
created

CreateOauthAuthCodesTable::getConnection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Support\Facades\Schema;
6
7
class CreateOauthAuthCodesTable extends Migration
8
{
9
    /**
10
     * The database schema.
11
     *
12
     * @var \Illuminate\Database\Schema\Builder
13
     */
14
    protected $schema;
15
16
    /**
17
     * Create a new migration instance.
18
     *
19
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
20
     */
21
    public function __construct()
22
    {
23
        $this->schema = Schema::connection($this->getConnection());
24
    }
25
26
    /**
27
     * Run the migrations.
28
     *
29
     * @return void
30
     */
31
    public function up()
32
    {
33
        $this->schema->create('oauth_auth_codes', function (Blueprint $table) {
34
            $table->string('id', 100)->primary();
35
            $table->unsignedBigInteger('user_id')->index();
36
            $table->unsignedBigInteger('client_id');
37
            $table->text('scopes')->nullable();
38
            $table->boolean('revoked');
39
            $table->dateTime('expires_at')->nullable();
40
        });
41
    }
42
43
    /**
44
     * Reverse the migrations.
45
     *
46
     * @return void
47
     */
48
    public function down()
49
    {
50
        $this->schema->dropIfExists('oauth_auth_codes');
51
    }
52
53
    /**
54
     * Get the migration connection name.
55
     *
56
     * @return string|null
57
     */
58
    public function getConnection()
59
    {
60
        return config('passport.storage.database.connection');
61
    }
62
}
63