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

CommentSeeder::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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

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