AlterRoleModule   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 30
c 1
b 0
f 0
dl 0
loc 58
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 25 1
A down() 0 19 1
1
<?php
2
3
use Illuminate\Support\Facades\Schema;
4
use Illuminate\Database\Schema\Blueprint;
5
use Uccello\Core\Database\Migrations\Migration;
6
use Uccello\Core\Models\Field;
7
use Uccello\Core\Models\Filter;
8
use Uccello\Core\Models\Module;
9
10
class AlterRoleModule extends Migration
11
{
12
    /**
13
     * Run the migrations.
14
     *
15
     * @return void
16
     */
17
    public function up()
18
    {
19
        Schema::table($this->tablePrefix.'roles', function(Blueprint $table) {
20
            $table->boolean('see_descendants_records')->after('description')->default(false);
21
        });
22
23
        $roleModule = Module::where('name', 'role')->first();
24
25
        $descriptionField = Field::where('module_id', $roleModule->id)->where('name', 'description')->first();
26
        $descriptionField->data = null;
0 ignored issues
show
Bug introduced by
The property data does not seem to exist on Uccello\Core\Models\Field. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
27
        $descriptionField->save();
28
29
        Field::create([
30
            'module_id' => $roleModule->id,
31
            'block_id' => $descriptionField->block_id,
0 ignored issues
show
Bug introduced by
The property block_id does not exist on Uccello\Core\Models\Field. Did you mean block?
Loading history...
32
            'name' => 'see_descendants_records',
33
            'uitype_id' => uitype('boolean')->id,
34
            'displaytype_id' => displaytype('everywhere')->id,
35
            'sequence' => 3,
36
            'data' => [ 'info' => 'field_info.see_descendants_records']
37
        ]);
38
39
        $filter = Filter::where('module_id', $roleModule->id)->where('name', 'filter.all')->first();
40
        $filter->columns = [ "name", "parent", "description", "see_descendants_records" ];
0 ignored issues
show
Bug introduced by
The property columns does not seem to exist on Uccello\Core\Models\Filter. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
41
        $filter->save();
42
    }
43
44
    /**
45
     * Reverse the migrations.
46
     *
47
     * @return void
48
     */
49
    public function down()
50
    {
51
        Schema::table($this->tablePrefix.'roles', function(Blueprint $table) {
52
            $table->dropColumn('see_descendants_records');
53
        });
54
55
        $roleModule = Module::where('name', 'role')->first();
56
57
        $descriptionField = Field::where('module_id', $roleModule->id)->where('name', 'description')->first();
58
        $descriptionField->data = [ 'large' => true ];
0 ignored issues
show
Bug introduced by
The property data does not seem to exist on Uccello\Core\Models\Field. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
59
        $descriptionField->save();
60
61
        Field::where('module_id', $roleModule->id)
62
            ->where('name', 'see_descendants_records')
63
            ->delete();
64
65
        $filter = Filter::where('module_id', $roleModule->id)->where('name', 'filter.all')->first();
66
        $filter->columns = [ "name", "description", "parent" ];
0 ignored issues
show
Bug introduced by
The property columns does not seem to exist on Uccello\Core\Models\Filter. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
67
        $filter->save();
68
    }
69
}
70