Completed
Push — master ( e07f46...7ee80f )
by
unknown
01:29
created

BantenprovSktmSeederMasterSktm::run()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 35
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 23
nc 2
nop 0
dl 0
loc 35
rs 8.8571
c 0
b 0
f 0
1
<?php
2
3
/* Require */
4
use Illuminate\Database\Seeder;
5
use Illuminate\Database\Eloquent\Model;
6
7
/* Models */
8
use Bantenprov\Sktm\Models\Bantenprov\Sktm\MasterSktm;
9
10
class BantenprovSktmSeederMasterSktm 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
        $master_sktms = (object) [
22
            (object) [
23
                'user_id' => '1',
24
                'juara' => '1',
25
                'tingkat' => '1',
26
                'nilai' => '10',              
27
                'bobot' => '1'                           
28
            ],
29
            (object) [
30
                'user_id' => '1',
31
                'juara' => '2',
32
                'tingkat' => '2',
33
                'nilai' => '20', 
34
                'bobot' => '2'                          
35
            ]
36
        ];
37
38
        foreach ($master_sktms as $master_sktm) {
39
            $model = MasterSktm::updateOrCreate(
40
                [
41
                   'user_id' => $master_sktm->user_id,
42
                   'juara' => $master_sktm->juara,
43
                   'tingkat' => $master_sktm->tingkat,
44
                   'nilai' => $master_sktm->nilai,
45
                   'bobot' => $master_sktm->bobot,
46
47
                ]
48
            );
49
            $model->save();
50
        }
51
	}
52
}
53
54
55