CreateCategoriesTable   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 5
dl 0
loc 34
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 16 1
A down() 0 4 1
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