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; |
|
|
|
|
27
|
|
|
$descriptionField->save(); |
28
|
|
|
|
29
|
|
|
Field::create([ |
30
|
|
|
'module_id' => $roleModule->id, |
31
|
|
|
'block_id' => $descriptionField->block_id, |
|
|
|
|
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" ]; |
|
|
|
|
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 ]; |
|
|
|
|
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" ]; |
|
|
|
|
67
|
|
|
$filter->save(); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.