Completed
Push — master ( 6f262b...7f1ac5 )
by David Martínez
02:06
created

LessonsSeeder::run()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 33
Code Lines 29

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 33
ccs 0
cts 31
cp 0
rs 8.8571
cc 1
eloc 29
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Scool\Timetables\Database\Seeds;
4
5
use Illuminate\Database\Seeder;
6
use Scool\Timetables\Models\Classroom;
7
use Scool\Timetables\Models\Day;
8
use Scool\Timetables\Models\Lesson;
9
use Scool\Timetables\Models\Location;
10
use Scool\Timetables\Models\Timeslot;
11
12
13
/**
14
 * Class LessonsSeeder
15
 * @package Scool\Timetables\Database\Seeds
16
 */
17
class LessonsSeeder extends Seeder
18
{
19
    /**
20
     * Run the database seeds.
21
     *
22
     * @return void
23
     */
24
    public function run()
25
    {
26
       $user = \App\User::find(2);
27
       $location = Location::find(3);
28
       $day = Day::find(2);
29
       $timeslot = Timeslot::find(7);
30
       $classroom = Classroom::find(1);
31
       $lesson = $this->createLesson();
32
       $location->lessons()->save($lesson);
33
       $day->lessons()->save($lesson);
34
       $timeslot->lessons()->save($lesson);
35
       $classroom->lessons()->save($lesson);
36
       $lesson->users()->save($user);
37
       $lesson->step1step2();
38
       //Second lesson - same day - hours touching
39
       $timeslot = Timeslot::find(8);
40
       $lesson = $this->createLesson();
41
        $location->lessons()->save($lesson);
42
        $day->lessons()->save($lesson);
43
        $timeslot->lessons()->save($lesson);
44
        $classroom->lessons()->save($lesson);
45
        $lesson->users()->save($user);
46
        $lesson->step1step2();
47
       //Third lesson - same day - timeslot way apart
48
        $timeslot = Timeslot::find(12);
49
        $lesson = $this->createLesson();
50
        $location->lessons()->save($lesson);
51
        $day->lessons()->save($lesson);
52
        $timeslot->lessons()->save($lesson);
53
        $classroom->lessons()->save($lesson);
54
        $lesson->users()->save($user);
55
        $lesson->step1step2();
56
    }
57
58
59
    /**
60
     * Creates a lesson
61
     *
62
     * @return mixed
63
     */
64
    private function createLesson()
65
    {
66
       return Lesson::Create([]);
67
//       $lesson->days()->save(Day::find($day));
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
68
//       $lesson->timeslots()->save(Timeslot::find($timeslot));
69
//       $lesson->classrooms()->save(Classroom::find($classroom));
70
//       return $lesson;
71
    }
72
}
73