Passed
Push — master ( 26152a...8fe73e )
by F
04:04
created

TypeSeeder::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 9
nc 2
nop 0
dl 0
loc 18
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * PWWEBPWWEB\Localisation\Database\Seeders\Address\Type Seeder.
5
 *
6
 * Standard seeder for the Address Types Model.
7
 *
8
 * @author    Frank Pillukeit <[email protected]>
9
 * @copyright 2020 pw-websolutions.com
10
 * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
11
 */
12
13
namespace v\Localisation\Database\Seeders\Address;
14
15
use Illuminate\Database\Seeder;
16
use Illuminate\Support\Facades\DB;
17
18
class TypeSeeder extends Seeder
19
{
20
    /**
21
     * Run the database seeds.
22
     *
23
     * @return void
24
     */
25
    public function run()
26
    {
27
        // Initializing variables.
28
        $createdAt = date('Y-m-d H:i:s');
29
        $types = [];
30
31
        // Definition of default countries.
32
        $types[] = ['name' => 'home', 'global' => true];
33
        $types[] = ['name' => 'work', 'global' => true];
34
        $types[] = ['name' => 'other', 'global' => true];
35
36
        foreach ($types as $id => $type) {
37
            $types[$id] = array_merge($type, ['created_at' => $createdAt, 'updated_at' => $createdAt]);
38
        }
39
40
        $tableNames = config('pwweb.localisation.table_names');
41
42
        DB::table($tableNames['address_types'])->insert($types);
43
    }
44
}
45