CreateCategoriesTable::up()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 16
rs 9.7333
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
use Kalnoy\Nestedset\NestedSet;
6
use Illuminate\Support\Facades\Schema;
7
use Illuminate\Database\Schema\Blueprint;
8
use Illuminate\Database\Migrations\Migration;
9
10
class CreateCategoriesTable extends Migration
11
{
12
    /**
13
     * Run the migrations.
14
     *
15
     * @return void
16
     */
17
    public function up(): void
18
    {
19
        Schema::create(config('rinvex.categories.tables.categories'), function (Blueprint $table) {
20
            // Columns
21
            $table->increments('id');
22
            $table->string('slug');
23
            $table->json('name');
24
            $table->json('description')->nullable();
25
            NestedSet::columns($table);
26
            $table->timestamps();
27
            $table->softDeletes();
28
29
            // Indexes
30
            $table->unique('slug');
31
        });
32
    }
33
34
    /**
35
     * Reverse the migrations.
36
     *
37
     * @return void
38
     */
39
    public function down(): void
40
    {
41
        Schema::dropIfExists(config('rinvex.categories.tables.categories'));
42
    }
43
}
44