Completed
Push — master ( c1d7cf...cc10b4 )
by
unknown
13s
created

BantenprovPrestasiSeederMasterPrestasi   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 46
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B run() 0 38 2
1
<?php
2
3
/* Require */
4
use Illuminate\Database\Seeder;
5
use Illuminate\Database\Eloquent\Model;
6
7
/* Models */
8
use Bantenprov\Prestasi\Models\Bantenprov\Prestasi\MasterPrestasi;
9
10
class BantenprovPrestasiSeederMasterPrestasi 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_prestasis = (object) [
22
            (object) [
23
                'user_id' => '1',
24
                'jenis_prestasi_id' => '1',
25
                'juara' => '1',
26
                'tingkat' => '1',
27
                'nilai' => '10',              
28
                'bobot' => '1'                           
29
            ],
30
            (object) [
31
                'user_id' => '1',
32
                'jenis_prestasi_id' => '2',
33
                'juara' => '2',
34
                'tingkat' => '2',
35
                'nilai' => '20', 
36
                'bobot' => '2'                          
37
            ]
38
        ];
39
40
        foreach ($master_prestasis as $master_prestasi) {
41
            $model = MasterPrestasi::updateOrCreate(
42
                [
43
                   'user_id' => $master_prestasi->user_id,
44
                   'jenis_prestasi_id' => $master_prestasi->jenis_prestasi_id,
45
                   'juara' => $master_prestasi->juara,
46
                   'tingkat' => $master_prestasi->tingkat,
47
                   'nilai' => $master_prestasi->nilai,
48
                   'bobot' => $master_prestasi->bobot,
49
50
                ]
51
            );
52
            $model->save();
53
        }
54
	}
55
}
56
57
58