ProjectsSeeder::run()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 24
rs 9.536
c 0
b 0
f 0
1
<?php
2
3
namespace Chriscreates\Projects\Seeds;
4
5
use Chriscreates\Projects\Models\Priority;
6
use Chriscreates\Projects\Models\Project;
7
use Chriscreates\Projects\Models\Status;
8
use Chriscreates\Projects\Models\Task;
9
use Illuminate\Database\Seeder;
10
11
class ProjectsSeeder extends Seeder
12
{
13
    private $statuses = [
14
        'Done',
15
        'In Progress',
16
        'Not Started',
17
        'Cancalled',
18
    ];
19
20
    private $priorities = [
21
        'Low',
22
        'Minor',
23
        'Moderate',
24
        'Significant',
25
        'Required',
26
    ];
27
28
    /**
29
     * Run the database seeds.
30
     *
31
     * @return void
32
     */
33
    public function run()
34
    {
35
        $statuses = collect($this->statuses)
36
        ->map(function ($status) {
37
            return factory(Status::class)->create(['name' => $status]);
38
        });
39
40
        $priorities = collect($this->priorities)
41
        ->map(function ($priority) {
42
            return factory(Priority::class)->create(['name' => $priority]);
43
        });
44
45
        $project = factory(Project::class)->create([
46
            'started_at' => now()->subMonth(),
47
            'delivered_at' => now()->subDays(2),
48
            'expected_at' => now(),
49
            'status_id' => $statuses->random()->id,
50
        ]);
51
52
        factory(Task::class, 4)
53
        ->create(['priority_id' => $priorities->random()->id])
54
        ->each
55
        ->assignTo($project);
56
    }
57
}
58