Completed
Push — master ( b6e961...8692a9 )
by Abdelrahman
15:05 queued 12:57
created

2016_05_15_205859_create_roles_table.php (1 issue)

Labels
Severity

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
declare(strict_types=1);
4
5
use Illuminate\Support\Facades\Schema;
6
use Illuminate\Database\Schema\Blueprint;
7
use Illuminate\Database\Migrations\Migration;
8
9
class CreateRolesTable extends Migration
10
{
11
    /**
12
     * Run the migrations.
13
     *
14
     * @return void
15
     */
16
    public function up()
17
    {
18
        Schema::create(config('rinvex.fort.tables.roles'), function (Blueprint $table) {
0 ignored issues
show
The method create() does not exist on Illuminate\Support\Facades\Schema. Did you maybe mean createFreshMockInstance()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
19
            // Columns
20
            $table->increments('id');
21
            $table->string('slug');
22
            $table->{$this->jsonable()}('name');
23
            $table->{$this->jsonable()}('description')->nullable();
24
            $table->timestamps();
25
            $table->softDeletes();
26
27
            // Indexes
28
            $table->unique('slug');
29
        });
30
    }
31
32
    /**
33
     * Reverse the migrations.
34
     *
35
     * @return void
36
     */
37
    public function down()
38
    {
39
        Schema::dropIfExists(config('rinvex.fort.tables.roles'));
40
    }
41
42
    /**
43
     * Get jsonable column data type.
44
     *
45
     * @return string
46
     */
47
    protected function jsonable()
48
    {
49
        return DB::connection()->getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME) === 'mysql'
50
               && version_compare(DB::connection()->getPdo()->getAttribute(PDO::ATTR_SERVER_VERSION), '5.7.8', 'ge')
51
            ? 'json' : 'text';
52
    }
53
}
54