Passed
Push — dependabot/npm_and_yarn/dev/st... ( 917c39...79f3f4 )
by
unknown
12:32 queued 07:14
created

CommentSeeder::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 8
rs 10
cc 2
nc 2
nop 0
1
<?php
2
3
use App\Models\Comment;
4
use App\Models\JobPoster;
5
use App\Models\User;
6
use Illuminate\Database\Seeder;
7
8
class CommentSeeder extends Seeder // phpcs:ignore
9
{
10
    /**
11
     * Run the database seeds.
12
     *
13
     * @return void
14
     */
15
    public function run(): void
16
    {
17
        $job_posters = JobPoster::all();
18
19
        foreach ($job_posters as $job_poster) {
20
            $job_poster->comments()->saveMany(factory(Comment::class, 3)->make([
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

20
            $job_poster->comments()->saveMany(/** @scrutinizer ignore-call */ factory(Comment::class, 3)->make([
Loading history...
21
                'job_poster_id' => $job_poster->id,
22
                'user_id' => $job_poster->manager->user_id,
23
            ]));
24
        }
25
    }
26
}
27