1 | <?php |
||
16 | class Lesson extends Model implements Transformable, Stateful |
||
17 | { |
||
18 | use TransformableTrait, StatefulTrait; |
||
19 | |||
20 | protected $fillable = ['id','location_id','day_id','timeslot_id','classroom_id', 'state']; |
||
21 | |||
22 | protected $events = [ |
||
23 | 'created' => LessonCreated::class |
||
24 | ]; |
||
25 | |||
26 | /** |
||
27 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
28 | */ |
||
29 | public function locations() |
||
33 | |||
34 | /** |
||
35 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
36 | */ |
||
37 | public function days() |
||
41 | |||
42 | /** |
||
43 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
44 | */ |
||
45 | public function timeslots() |
||
49 | |||
50 | /** |
||
51 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
52 | */ |
||
53 | public function classrooms() |
||
57 | |||
58 | /** |
||
59 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
60 | */ |
||
61 | public function users() |
||
65 | |||
66 | /** |
||
67 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
68 | */ |
||
69 | public function submodules() |
||
73 | |||
74 | /** |
||
75 | * States. |
||
76 | * |
||
77 | * @var array |
||
78 | */ |
||
79 | protected $states = [ |
||
80 | 'step1' => ['initial' => true], |
||
81 | 'step2' => ['final' => true] |
||
82 | ]; |
||
83 | /** |
||
84 | * Transaction State Transitions |
||
85 | * |
||
86 | * @var array |
||
87 | */ |
||
88 | protected $transitions = [ |
||
89 | 'step1step2' => [ |
||
90 | 'from' => 'step1', |
||
91 | 'to' => 'step2' |
||
92 | ], |
||
93 | 'step2step1' => [ |
||
94 | 'from' => 'step2', |
||
95 | 'to' => 'step1' |
||
96 | ] |
||
97 | ]; |
||
98 | /** |
||
99 | * @return bool |
||
100 | */ |
||
101 | protected function validateStep1step2() |
||
108 | /** |
||
109 | * @return bool |
||
110 | */ |
||
111 | protected function validateStep2step1() |
||
115 | } |
||
116 |