1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Scool\Timetables\Models; |
4
|
|
|
|
5
|
|
|
use Acacha\Stateful\Contracts\Stateful; |
6
|
|
|
use Acacha\Stateful\Traits\StatefulTrait; |
7
|
|
|
use Illuminate\Database\Eloquent\Model; |
8
|
|
|
use Prettus\Repository\Contracts\Transformable; |
9
|
|
|
use Prettus\Repository\Traits\TransformableTrait; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class Lesson |
13
|
|
|
* @package Scool\Timetables\Models |
14
|
|
|
*/ |
15
|
|
|
class Lesson extends Model implements Transformable, Stateful |
16
|
|
|
{ |
17
|
|
|
use TransformableTrait, StatefulTrait; |
18
|
|
|
|
19
|
|
|
protected $fillable = ['id','location_id','day_id','timeslot_id','classroom_id']; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
23
|
|
|
*/ |
24
|
|
|
public function locations() |
25
|
|
|
{ |
26
|
|
|
return $this->belongsTo(\Scool\Timetables\Models\Location::class); //TODO |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
31
|
|
|
*/ |
32
|
|
|
public function days() |
33
|
|
|
{ |
34
|
|
|
return $this->belongsTo(\Scool\Timetables\Models\Day::class); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
39
|
|
|
*/ |
40
|
|
|
public function timeslots() |
41
|
|
|
{ |
42
|
|
|
return $this->belongsTo(\Scool\Timetables\Models\Timeslot::class); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
47
|
|
|
*/ |
48
|
|
|
public function classrooms() |
49
|
|
|
{ |
50
|
|
|
return $this->belongsTo(\Scool\Timetables\Models\Classroom::class); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
55
|
|
|
*/ |
56
|
|
|
public function users() |
57
|
|
|
{ |
58
|
|
|
return $this->belongsToMany(\App\User::class); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
63
|
|
|
*/ |
64
|
|
|
public function submodules() |
65
|
|
|
{ |
66
|
|
|
return $this->belongsToMany(\Submodule::class); //TODO |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
protected $states = [ |
70
|
|
|
// 'draft' => ['inital' => true], |
|
|
|
|
71
|
|
|
// 'processing', |
72
|
|
|
// 'errored', |
73
|
|
|
// 'active', |
74
|
|
|
// 'closed' => ['final' => true] |
75
|
|
|
]; |
76
|
|
|
|
77
|
|
|
protected $transitions = [ |
78
|
|
|
// 'process' => [ |
|
|
|
|
79
|
|
|
// 'from' => ['draft', 'errored'], |
80
|
|
|
// 'to' => 'processing' |
81
|
|
|
// ], |
82
|
|
|
// 'activate' => [ |
83
|
|
|
// 'from' => 'processing', |
84
|
|
|
// 'to' => 'active' |
85
|
|
|
// ], |
86
|
|
|
// 'fail' => [ |
87
|
|
|
// 'from' => 'processing', |
88
|
|
|
// 'to' => 'errored' |
89
|
|
|
// ], |
90
|
|
|
// 'close' => [ |
91
|
|
|
// 'from' => 'active', |
92
|
|
|
// 'to' => 'close' |
93
|
|
|
// ] |
94
|
|
|
]; |
95
|
|
|
|
96
|
|
|
// /** |
|
|
|
|
97
|
|
|
// * @return bool |
98
|
|
|
// */ |
99
|
|
|
// protected function validateProcess() |
100
|
|
|
// { |
101
|
|
|
// $validate = true; |
102
|
|
|
// if (!$validate) { |
103
|
|
|
// $this->addValidateProcessMessage(); |
104
|
|
|
// } |
105
|
|
|
// |
106
|
|
|
// return $validate; |
107
|
|
|
// } |
108
|
|
|
// |
109
|
|
|
// /** |
110
|
|
|
// * @return bool |
111
|
|
|
// */ |
112
|
|
|
// protected function validateActivate() |
113
|
|
|
// { |
114
|
|
|
// //dd("validateActivate"); |
115
|
|
|
// return true; |
116
|
|
|
// } |
117
|
|
|
|
118
|
|
|
} |
119
|
|
|
|
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.