Completed
Push — master ( 366501...56d9b3 )
by
unknown
04:20 queued 01:06
created

BantenprovOrangTuaSeederOrangTua::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 51
Code Lines 41

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 41
nc 2
nop 0
dl 0
loc 51
rs 9.4109
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/* Require */
4
use Illuminate\Database\Seeder;
5
use Illuminate\Database\Eloquent\Model;
6
7
/* Models */
8
use Bantenprov\OrangTua\Models\Bantenprov\OrangTua\OrangTua;
9
10
class BantenprovOrangTuaSeederOrangTua 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
        $orang_tuas = (object) [
21
            (object) [
22
                'nomor_un' => '123456789',
23
                'no_kk' => '12345',
24
                'alamat_ortu' => 'alamat 1',
25
                'nama_ayah' => 'nama ayah 1',
26
                'nama_ibu' => 'nama ibu 1',
27
                'kerja_ayah' => 'pekerjaan ayah 1',
28
                'pendidikan_ayah' => 'pendidikan ayah 1',
29
                'kerja_ibu' => 'pekerjaan ibu 1',
30
                'pendidikan_ibu' => 'pendidikan ibu 1',
31
                'no_telp' => '085212345',
32
                'user_id' => '1',
33
            ],
34
            (object) [
35
                'nomor_un' => '123456730',
36
                'no_kk' => '123653',
37
                'alamat_ortu' => 'alamat 2',
38
                'nama_ayah' => 'nama ayah 2',
39
                'nama_ibu' => 'nama ibu 2',
40
                'kerja_ayah' => 'pekerjaan ayah 2',
41
                'pendidikan_ayah' => 'pendidikan ayah 2',
42
                'kerja_ibu' => 'pekerjaan ibu 2',
43
                'pendidikan_ibu' => 'pendidikan ibu 2',
44
                'no_telp' => '085222345',
45
                'user_id' => '2',
46
            ]
47
        ];
48
49
        foreach ($orang_tuas as $orang_tua) {
50
            $model = OrangTua::create(
51
                [
52
                    'nomor_un' => $orang_tua['nomor_un'],
53
                    'no_kk' => $orang_tua['no_kk'],
54
                    'alamat_ortu' => $orang_tua['alamat_ortu'],
55
                    'nama_ayah' => $orang_tua['nama_ayah'],
56
                    'nama_ibu' => $orang_tua['nama_ibu'],
57
                    'kerja_ayah' => $orang_tua['kerja_ayah'],
58
                    'pendidikan_ayah' => $orang_tua['pendidikan_ayah'],
59
                    'kerja_ibu' => $orang_tua['kerja_ibu'],
60
                    'pendidikan_ibu' => $orang_tua['pendidikan_ibu'],
61
                    'no_telp' => $orang_tua['no_telp'],
62
                    'user_id' => $orang_tua['user_id'],
63
                ]
64
            );
65
            $model->save();
66
        }
67
	}
68
}
69