DefaultBlockedTypeTableSeeder   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 31
dl 0
loc 72
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 65 3
1
<?php
2
3
namespace jeremykenedy\LaravelBlocker\Database\Seeds;
4
5
use Illuminate\Database\Seeder;
0 ignored issues
show
Bug introduced by
The type Illuminate\Database\Seeder was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use jeremykenedy\LaravelBlocker\App\Models\BlockedType;
7
8
class DefaultBlockedTypeTableSeeder extends Seeder
9
{
10
    /**
11
     * Run the database seeds.
12
     *
13
     * @return void
14
     */
15
    public function run()
16
    {
17
        /*
18
         * Blocked Types
19
         *
20
         */
21
        $BlockedTypes = [
22
            [
23
                'slug' => 'email',
24
                'name' => 'E-mail',
25
            ],
26
            [
27
                'slug' => 'ipAddress',
28
                'name' => 'IP Address',
29
            ],
30
            [
31
                'slug' => 'domain',
32
                'name' => 'Domain Name',
33
            ],
34
            [
35
                'slug' => 'user',
36
                'name' => 'User',
37
            ],
38
            [
39
                'slug' => 'city',
40
                'name' => 'City',
41
            ],
42
            [
43
                'slug' => 'state',
44
                'name' => 'State',
45
            ],
46
            [
47
                'slug' => 'country',
48
                'name' => 'Country',
49
            ],
50
            [
51
                'slug' => 'countryCode',
52
                'name' => 'Country Code',
53
            ],
54
            [
55
                'slug' => 'continent',
56
                'name' => 'Continent',
57
            ],
58
            [
59
                'slug' => 'region',
60
                'name' => 'Region',
61
            ],
62
        ];
63
64
        /*
65
         * Add Blocked Types
66
         *
67
         */
68
        foreach ($BlockedTypes as $BlockedType) {
69
            $newBlockedType = BlockedType::where('slug', '=', $BlockedType['slug'])
70
                ->withTrashed()
71
                ->first();
72
            if ($newBlockedType === null) {
73
                $newBlockedType = BlockedType::create([
0 ignored issues
show
Unused Code introduced by
The assignment to $newBlockedType is dead and can be removed.
Loading history...
74
                    'slug' => $BlockedType['slug'],
75
                    'name' => $BlockedType['name'],
76
                ]);
77
            }
78
        }
79
        echo "\e[32mSeeding:\e[0m DefaultBlockedTypeTableSeeder\r\n";
80
    }
81
}
82