Completed
Push — master ( bbc98f...1d64bf )
by
unknown
03:50
created

BantenprovNilaiSeederNilai   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B run() 0 32 2
1
<?php
2
3
/* Require */
4
use Illuminate\Database\Seeder;
5
use Illuminate\Database\Eloquent\Model;
6
7
/* Models */
8
use Bantenprov\Nilai\Models\Bantenprov\Nilai\Nilai;
9
10
class BantenprovNilaiSeederNilai 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
        $nilais = (object) [
22
            (object) [
23
                'siswa_id' => '1',
24
                'label' => 'Nilai 1',
25
                'description' => 'Nilai satu'
26
            ],
27
            (object) [
28
                'siswa_id' => '2',
29
                'label' => 'Nilai 2',
30
                'description' => 'Nilai dua',
31
            ]
32
        ];
33
34
        foreach ($nilais as $nilai) {
35
            $model = Nilai::updateOrCreate(
36
                [
37
                    'siswa_id' => $nilai->siswa_id,
38
                ],
39
                [
40
                    'label' => $nilai->label,
41
                ],
42
                [
43
                    'description' => $nilai->description,
44
                ]
45
            );
46
            $model->save();
47
        }
48
	}
49
}
50