AddUsersRolesRl::down()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 9
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
use Illuminate\Support\Facades\Schema;
4
use Uccello\Core\Database\Migrations\Migration;
5
use Uccello\Core\Models\Module;
6
use Uccello\Core\Models\Relatedlist;
7
8
class AddUsersRolesRl extends Migration
9
{
10
    /**
11
     * Run the migrations.
12
     *
13
     * @return void
14
     */
15
    public function up()
16
    {
17
        $userModule = Module::where('name', 'user')->first();
18
        $groupModule = Module::where('name', 'group')->first();
19
20
        Relatedlist::create([
21
            'module_id' => $userModule->id,
22
            'related_module_id' => $groupModule->id,
23
            'tab_id' => null,
24
            'label' => 'relatedlist.groups',
25
            'type' => 'n-n',
26
            'method' => 'getRelatedList',
27
            'sequence' => 1,
28
            'data' => [ 'actions' => [ 'add', 'select' ] ]
29
        ]);
30
    }
31
32
    /**
33
     * Reverse the migrations.
34
     *
35
     * @return void
36
     */
37
    public function down()
38
    {
39
        $userModule = Module::where('name', 'user')->first();
40
        $groupModule = Module::where('name', 'group')->first();
41
42
        Relatedlist::where('module_id', $userModule->id)
43
            ->where('related_module_id', $groupModule->id)
44
            ->where('label', 'relatedlist.groups')
45
            ->delete();
46
    }
47
}
48