Completed
Push — master ( 5e49b6...2ab591 )
by David Martínez
07:18
created

LessonsSeeder::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
ccs 0
cts 15
cp 0
rs 9.4285
cc 1
eloc 13
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
    }
39
40
41
    /**
42
     * Creates a lesson
43
     *
44
     * @return mixed
45
     */
46
    private function createLesson()
47
    {
48
       return Lesson::firstOrCreate([]);
49
//       $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...
50
//       $lesson->timeslots()->save(Timeslot::find($timeslot));
51
//       $lesson->classrooms()->save(Classroom::find($classroom));
52
//       return $lesson;
53
    }
54
}
55