Passed
Push — master ( 6bbf15...aead9d )
by Jonathan
19:29
created

AddUsersRolesRl::up()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 14
rs 9.9
cc 1
nc 1
nop 0
1
<?php
2
3
use Illuminate\Support\Facades\Schema;
0 ignored issues
show
Bug introduced by
The type Illuminate\Support\Facades\Schema was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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