Passed
Push — task/upgrade-to-laravel-8 ( 06df3c...4c1b1e )
by Chris
03:46
created

ExperienceSkillSeeder::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 32
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 23
nc 2
nop 0
dl 0
loc 32
rs 9.552
c 0
b 0
f 0
1
<?php
2
3
namespace Database\Seeders;
4
5
use App\Models\Skill;
6
use App\Models\ExperienceWork;
7
use App\Models\ExperienceAward;
8
use App\Models\ExperiencePersonal;
9
use App\Models\ExperienceCommunity;
10
use App\Models\ExperienceEducation;
11
use Illuminate\Database\Seeder;
12
13
class ExperienceSkillSeeder extends Seeder // phpcs:ignore
14
{
15
    /**
16
     * Run the Experience Skills seeds.
17
     *
18
     * @return void
19
     */
20
    public function run()
21
    {
22
        factory(ExperienceWork::class, 8)->create();
0 ignored issues
show
Bug introduced by
The function factory was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

22
        /** @scrutinizer ignore-call */ 
23
        factory(ExperienceWork::class, 8)->create();
Loading history...
23
        factory(ExperienceAward::class, 5)->create();
24
        factory(ExperiencePersonal::class, 6)->create();
25
        factory(ExperienceEducation::class, 7)->create();
26
        factory(ExperienceCommunity::class, 4)->create();
27
28
        $skills = Skill::all();
29
30
        foreach ($skills as $skill) {
31
            $skill->experiences_work()
32
                ->attach(ExperienceWork::inRandomOrder()->first(), [
33
                    'justification' => 'Because I had some job.'
34
                ]);
35
            $skill->experiences_personal()
36
                ->attach(ExperiencePersonal::inRandomOrder()->first(), [
37
                    'justification' => 'Because I did this thing.'
38
                ]);
39
            $skill->experiences_education()
40
                ->attach(ExperienceEducation::inRandomOrder()->first(), [
41
                    'justification' => 'Because a piece of paper has my name on it.'
42
                ]);
43
            $skill->experiences_award()
44
                ->attach(ExperienceAward::inRandomOrder()->first(), [
45
                    'justification' => 'Because I got a prize for participating.'
46
                ]);
47
            $skill->experiences_community()
48
                ->attach(ExperienceCommunity::inRandomOrder()->first(), [
49
                    'justification' => 'Because I am a communist.'
50
                ]);
51
            $skill->save();
52
        }
53
    }
54
}
55