AddDisplaytypes::up()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 2
eloc 9
c 2
b 1
f 0
nc 2
nop 0
dl 0
loc 15
rs 9.9666
1
<?php
2
3
use Illuminate\Support\Facades\Artisan;
4
use Uccello\Core\Database\Migrations\Migration;
5
use Uccello\Core\Models\Displaytype;
6
7
class AddDisplaytypes extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        $displaytypes = [
17
            'create_detail'    => 'Uccello\Core\Fields\Displaytype\CreateDetail',
18
            'list_only'        => 'Uccello\Core\Fields\Displaytype\ListOnly',
19
        ];
20
21
        foreach ($displaytypes as $name => $class) {
22
            $displaytype = new Displaytype();
23
            $displaytype->name = $name;
0 ignored issues
show
Bug introduced by
The property name does not seem to exist on Uccello\Core\Models\Displaytype. 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...
24
            $displaytype->class = $class;
0 ignored issues
show
Bug introduced by
The property class does not seem to exist on Uccello\Core\Models\Displaytype. 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...
25
            $displaytype->save();
26
        }
27
28
        Artisan::call('cache:clear');
29
    }
30
31
    /**
32
     * Reverse the migrations.
33
     *
34
     * @return void
35
     */
36
    public function down()
37
    {
38
        Displaytype::where('name', 'create_detail')
39
            ->orWhere('name', 'list_only')
40
            ->delete();
41
42
        Artisan::call('cache:clear');
43
    }
44
}