TimeslotsSeeder::createTimeslot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 8
rs 9.4285
c 1
b 0
f 0
ccs 0
cts 8
cp 0
cc 1
eloc 5
nc 1
nop 3
crap 2
1
<?php
2
3
namespace Scool\Timetables\Database\Seeds;
4
5
use Illuminate\Database\Seeder;
6
use Scool\Timetables\Models\Shift;
7
use Scool\Timetables\Models\Timeslot;
8
9
/**
10
 * Class TimeslotsSeeder
11
 * @package Scool\Timetables\Database\Seeds
12
 */
13
class TimeslotsSeeder extends Seeder
14
{
15
    /**
16
     * Run the database seeds.
17
     *
18
     * @return void
19
     */
20
    public function run()
21
    {
22
        $mati = Shift::find(1);
23
        $tarda = Shift::find(2);
24
        $tslt = $this->createTimeslot('Primera', "08:00", "09:00");
25
        $tslt->shifts()->save($mati);
26
        $tslt =$this->createTimeslot('Segona', "09:00", "10:00");
27
        $tslt->shifts()->save($mati);
28
        $tslt =$this->createTimeslot('Tercera', "10:00", "11:00");
29
        $tslt->shifts()->save($mati);
30
        $tslt =$this->createTimeslot('Quarta', "11:30", "12:30");
31
        $tslt->shifts()->save($mati);
32
        $tslt =$this->createTimeslot('Cinquena', "12:30", "13:30");
33
        $tslt->shifts()->save($mati);
34
        $tslt =$this->createTimeslot('Sisena', "13:30", "14:30");
35
        $tslt->shifts()->save($mati);
36
        $tslt =$this->createTimeslot('Setena', "15:30", "16:30");
37
        $tslt->shifts()->save($tarda);
38
        $tslt = $this->createTimeslot('Vuitena', "16:30", "17:30");
39
        $tslt->shifts()->save($tarda);
40
        $tslt =$this->createTimeslot('Novena', "17:30", "18:30");
41
        $tslt->shifts()->save($tarda);
42
        $tslt =$this->createTimeslot('Desena', "19:00", "20:00");
43
        $tslt->shifts()->save($tarda);
44
        $tslt =$this->createTimeslot('Onzena', "20:00", "21:00");
45
        $tslt->shifts()->save($tarda);
46
        $tslt =$this->createTimeslot('Dotzena', "21:00", "22:00");
47
        $tslt->shifts()->save($tarda);
48
    }
49
50
    /**
51
     * @param $name
52
     * @param $code
53
     * @param $lective
54
     */
55
    private function createTimeslot($name, $init_hour, $final_hour)
56
    {
57
        return Timeslot::firstOrCreate([
58
            'name' => $name,
59
            'init_hour' => $init_hour,
60
            'final_hour' => $final_hour
61
        ]);
62
    }
63
}
64