Completed
Pull Request — master (#3)
by
unknown
01:42
created

BantenprovProgramKeahlianSeederProgramKeahlian::run()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 33
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 20
nc 2
nop 0
dl 0
loc 33
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\ProgramKeahlian\Models\Bantenprov\ProgramKeahlian\ProgramKeahlian;
9
10
class BantenprovProgramKeahlianSeederProgramKeahlian 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
        $program_keahlians = (object) [
22
            (object) [
23
                'user_id'       => '1',
24
                'label'         => 'label1',
25
                'keterangan'    => 'keterangan 1'
26
            ],
27
            (object) [
28
                'user_id'       => '2',
29
                'label'         => 'label2',
30
                'keterangan'    => 'keterangan2'
31
            ],
32
            (object) [
33
                'user_id'       => '3',
34
                'label'         => 'label3',
35
                'keterangan'    => 'keterangan3'
36
            ],
37
            
38
        ];
39
40
        foreach ($program_keahlians as $program_keahlian) {
41
            $model = ProgramKeahlian::updateOrCreate(
42
                [
43
                    'label' => $program_keahlian->label
44
                    'keterangan' => $program_keahlian->keterangan,
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ']'
Loading history...
45
                    'user_id'   => $program_keahlian->user_id,
46
                ]
47
            );
48
            $model->save();
49
        }
50
    }
51
}
52