Passed
Push — master ( 3c4def...f95ae3 )
by Jonathan
19:33 queued 09:29
created

RenameRelatedlistWidgetClass::up()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Uccello\Core\Models\Widget;
5
6
class RenameRelatedlistWidgetClass extends Migration
7
{
8
    /**
9
     * Run the migrations.
10
     *
11
     * @return void
12
     */
13
    public function up()
14
    {
15
        $widgets = Widget::where('class', 'Uccello\Core\Widgets\Relatedlist')->get();
16
17
        foreach ($widgets as $widget) {
18
            $widget->class = 'Uccello\Core\Widgets\RelatedlistWidget';
0 ignored issues
show
Bug introduced by
The property class does not seem to exist on Uccello\Core\Models\Widget. 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...
19
            $widget->save();
20
        }
21
    }
22
23
    /**
24
     * Reverse the migrations.
25
     *
26
     * @return void
27
     */
28
    public function down()
29
    {
30
        $widgets = Widget::where('class', 'Uccello\Core\Widgets\RelatedlistWidget')->get();
31
32
        foreach ($widgets as $widget) {
33
            $widget->class = 'Uccello\Core\Widgets\Relatedlist';
0 ignored issues
show
Bug introduced by
The property class does not seem to exist on Uccello\Core\Models\Widget. 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...
34
            $widget->save();
35
        }
36
    }
37
}
38