AddDisplaytypes   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 14
c 2
b 1
f 0
dl 0
loc 36
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A down() 0 7 1
A up() 0 15 2
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
}