Completed
Push — master ( 637d66...6ee175 )
by
unknown
09:03
created

BantenprovVueOpdSeederVueOpd::run()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 29
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 8.8571
c 0
b 0
f 0
cc 2
eloc 19
nc 2
nop 0
1
<?php
2
3
/* Require */
4
use Illuminate\Database\Seeder;
5
use Illuminate\Database\Eloquent\Model;
6
7
/* Models */
8
use Bantenprov\VueOpd\Models\Bantenprov\VueOpd\VueOpd;
9
10
class BantenprovVueOpdSeederVueOpd extends Seeder
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
11
{
12
    /**
13
     * Run the database seeds.
14
     *
15
     * @return void
16
     */
17
	public function run()
18
	{
19
        Model::unguard();
20
21
        $file       = file_get_contents(public_path('json/bantenprov/vue-opd/vue-opd-data.json'));
22
        $json       = json_decode($file, true);
23
        $vue_opds   = array_get($json, '2.data');
24
25
        foreach ($vue_opds as $vue_opd) {
26
            $model = VueOpd::updateOrCreate(
27
                [
28
                    'id' => $vue_opd['id'],
29
                ],
30
                [
31
                    'kunker' => $vue_opd['kunker'],
32
                    'name' => $vue_opd['name'],
33
                    'kunker_sinjab' => $vue_opd['kunker_sinjab'],
34
                    'kunker_simral' => $vue_opd['kunker_simral'],
35
                    'levelunker' => $vue_opd['levelunker'],
36
                    'njab' => $vue_opd['njab'],
37
                    'npej' => $vue_opd['npej'],
38
                    '_lft' => $vue_opd['_lft'],
39
                    '_rgt' => $vue_opd['_rgt'],
40
                    'parent_id' => $vue_opd['parent_id'],
41
                ]
42
            );
43
            $model->save();
44
        }
45
	}
46
}
47