Passed
Push — master ( c92e71...89beee )
by Jonathan
25:53
created

AddDisplaytypes   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 32
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A down() 0 5 1
A up() 0 12 2
1
<?php
2
3
use Uccello\Core\Database\Migrations\Migration;
4
use Uccello\Core\Models\Displaytype;
5
6
class AddDisplaytypes extends Migration
7
{
8
    /**
9
     * Run the migrations.
10
     *
11
     * @return void
12
     */
13
    public function up()
14
    {
15
        $displaytypes = [
16
            'create_detail'    => 'Uccello\Core\Fields\Displaytype\CreateDetail',
17
            'list_only'        => 'Uccello\Core\Fields\Displaytype\ListOnly',
18
        ];
19
20
        foreach ($displaytypes as $name => $class) {
21
            $displaytype = new Displaytype();
22
            $displaytype->name = $name;
23
            $displaytype->class = $class;
24
            $displaytype->save();
25
        }
26
    }
27
28
    /**
29
     * Reverse the migrations.
30
     *
31
     * @return void
32
     */
33
    public function down()
34
    {
35
        Displaytype::where('name', 'create_detail')
36
            ->orWhere('name', 'list_only')
37
            ->delete();
38
    }
39
}
40