Completed
Pull Request — dev (#297)
by Tristan
11:17
created

TeamCultureSeeder::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 2
dl 0
loc 3
rs 10
c 2
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
use Illuminate\Database\Seeder;
4
use App\Models\Manager;
5
use App\Models\TeamCulture;
6
7
class TeamCultureSeeder extends Seeder
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
8
{
9
    protected $faker;
10
    protected $faker_fr;
11
12
    public function __construct(Faker\Generator $faker) {
13
        $this->faker = $faker;
14
        $this->faker_fr = Faker\Factory::create('fr');
15
    }
16
17
    /**
18
     * Run the Users table seeds.
19
     *
20
     * @return void
21
     */
22
    public function run()
23
    {
24
        $faker = $this->faker;
25
        $faker_fr = $this->faker_fr;
26
27
        //Find all managers that don't have a work environment yet
28
        $managers = Manager::doesntHave('team_culture')->get();
29
30
        foreach($managers as $manager) {
31
            $teamCulture = new TeamCulture();
32
            $teamCulture->manager_id = $manager->id;
33
            $teamCulture->fill([
34
                'team_size' => $faker->numberBetween(5, 15),
35
                'gc_directory_url' => $faker->url(),
36
                'en' => [
37
                    'narrative_text' => $faker->paragraphs(2,true),
38
                    'operating_context' => $faker->paragraph(),
39
                    'what_we_value' => $faker->paragraph(),
40
                    'how_we_work' => $faker->paragraph()
41
                ],
42
                'fr' => [
43
                    'narrative_text' => $faker_fr->paragraphs(2,true),
44
                    'operating_context' => $faker_fr->paragraph(),
45
                    'what_we_value' => $faker_fr->paragraph(),
46
                    'how_we_work' => $faker_fr->paragraph()
47
                ]
48
            ]);
49
50
            $teamCulture->save();
51
        }
52
    }
53
}
54