@@ -34,7 +34,7 @@ |
||
34 | 34 | parent::boot(); |
35 | 35 | |
36 | 36 | // when deleting a user, also delete any teacher and students accounts associated to this user. |
37 | - static::deleting(function (self $user) { |
|
37 | + static::deleting(function(self $user) { |
|
38 | 38 | if ($user->student()->exists()) { |
39 | 39 | Attendance::where('student_id', $user->student->id)->delete(); |
40 | 40 | Enrollment::where('student_id', $user->student->id)->delete(); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public function getPendingAttendanceAttribute() |
178 | 178 | { |
179 | - $events = Event::where(function ($query) { |
|
179 | + $events = Event::where(function($query) { |
|
180 | 180 | $query->where('course_id', $this->id); |
181 | 181 | $query->where('exempt_attendance', '!=', true); |
182 | 182 | $query->where('exempt_attendance', '!=', 1); |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | foreach ($courseTimes as $courseTime) { |
248 | 248 | $initial = $daysInitials[$courseTime->day]; |
249 | 249 | |
250 | - if (! isset($parsedCourseTimes[$initial])) { |
|
250 | + if (!isset($parsedCourseTimes[$initial])) { |
|
251 | 251 | $parsedCourseTimes[$initial] = []; |
252 | 252 | } |
253 | 253 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | |
323 | 323 | public function eventsWithExpectedAttendance() |
324 | 324 | { |
325 | - return $this->events()->where(function ($query) { |
|
325 | + return $this->events()->where(function($query) { |
|
326 | 326 | $query->where('exempt_attendance', '!=', true); |
327 | 327 | $query->where('exempt_attendance', '!=', 1); |
328 | 328 | $query->orWhereNull('exempt_attendance'); |
@@ -186,15 +186,15 @@ |
||
186 | 186 | $eventsWithMissingAttendance = []; |
187 | 187 | |
188 | 188 | $eventsWithExpectedAttendance = $this->events() |
189 | - ->where(function ($query) { |
|
189 | + ->where(function($query) { |
|
190 | 190 | $query->where('exempt_attendance', '!=', true); |
191 | 191 | $query->where('exempt_attendance', '!=', 1); |
192 | 192 | $query->orWhereNull('exempt_attendance'); |
193 | 193 | }) |
194 | 194 | ->where('course_id', '!=', null) |
195 | - ->whereHas('course', function (Builder $query) use ($period) { |
|
195 | + ->whereHas('course', function(Builder $query) use ($period) { |
|
196 | 196 | return $query->where('period_id', $period->id) |
197 | - ->where(function ($query) { |
|
197 | + ->where(function($query) { |
|
198 | 198 | $query->where('exempt_attendance', '!=', true); |
199 | 199 | $query->where('exempt_attendance', '!=', 1); |
200 | 200 | $query->orWhereNull('exempt_attendance'); |
@@ -208,8 +208,8 @@ |
||
208 | 208 | foreach ($course->enrollments as $enrollment) { |
209 | 209 | // if a student has no attendance record for the class (event) |
210 | 210 | $hasNotAttended = $course->attendance->where('student_id', $enrollment->student_id) |
211 | - ->where('event_id', $event->id) |
|
212 | - ->isEmpty(); |
|
211 | + ->where('event_id', $event->id) |
|
212 | + ->isEmpty(); |
|
213 | 213 | |
214 | 214 | // count one and break loop |
215 | 215 | if ($hasNotAttended) { |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | { |
135 | 135 | $period = self::where('id', '<', $this->id)->orderBy('id', 'desc')->first(); |
136 | 136 | |
137 | - if (! $period == null) { |
|
137 | + if (!$period == null) { |
|
138 | 138 | return $period; |
139 | 139 | } else { |
140 | 140 | return self::first(); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | public function getCoursesWithPendingAttendanceAttribute() |
196 | 196 | { |
197 | 197 | // get all courses for period and preload relations |
198 | - $courses = $this->courses()->where(function ($query) { |
|
198 | + $courses = $this->courses()->where(function($query) { |
|
199 | 199 | $query->where('exempt_attendance', '!=', true); |
200 | 200 | $query->where('exempt_attendance', '!=', 1); |
201 | 201 | $query->orWhereNull('exempt_attendance'); |
@@ -20,14 +20,14 @@ |
||
20 | 20 | parent::boot(); |
21 | 21 | |
22 | 22 | // do not save already existing leaves |
23 | - static::saving(function (self $leave) { |
|
23 | + static::saving(function(self $leave) { |
|
24 | 24 | if (self::where('teacher_id', $leave->teacher_id)->where('date', $leave->date)->count() > 0) { |
25 | 25 | return false; |
26 | 26 | } |
27 | 27 | }); |
28 | 28 | |
29 | 29 | // when a leave is, we detach the events from the teacher |
30 | - static::saved(function (self $leave) { |
|
30 | + static::saved(function(self $leave) { |
|
31 | 31 | $events = Event::where('teacher_id', $leave->teacher_id)->whereDate('start', $leave->date)->get(); |
32 | 32 | foreach ($events as $event) { |
33 | 33 | $event->teacher_id = null; |
@@ -21,7 +21,7 @@ |
||
21 | 21 | parent::boot(); |
22 | 22 | |
23 | 23 | // when a result is added, send a notification |
24 | - static::saved(function (self $result) { |
|
24 | + static::saved(function(self $result) { |
|
25 | 25 | Mail::to($result->enrollment->student->user->email) |
26 | 26 | ->locale($result->enrollment->student->locale) |
27 | 27 | ->queue(new ResultNotification($result->enrollment->course, $result->enrollment->student->user)); |
@@ -15,12 +15,12 @@ |
||
15 | 15 | parent::boot(); |
16 | 16 | |
17 | 17 | // when a coursetime is added, we should create corresponding events |
18 | - static::created(function ($coursetime) { |
|
18 | + static::created(function($coursetime) { |
|
19 | 19 | $coursetime->create_events(); |
20 | 20 | }); |
21 | 21 | |
22 | 22 | // when a coursetime is deleted, we should delete all associated future events |
23 | - static::deleted(function ($coursetime) { |
|
23 | + static::deleted(function($coursetime) { |
|
24 | 24 | $coursetime->events()->delete(); |
25 | 25 | // todo delete only future events |
26 | 26 | }); |
@@ -23,7 +23,7 @@ |
||
23 | 23 | parent::boot(); |
24 | 24 | |
25 | 25 | // when an attendance record is added, we check if this is an absence |
26 | - static::saved(function (self $attendance) { |
|
26 | + static::saved(function(self $attendance) { |
|
27 | 27 | if ($attendance->attendance_type_id == 4) { // todo move to configurable settings |
28 | 28 | Log::info('Absence marked for student '.$attendance->student->name); |
29 | 29 | // will check the record again and send a notification if it hasn't changed |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | parent::boot(); |
30 | 30 | |
31 | 31 | // when deleting a student, also delete any enrollments, grades and attendance related to this student |
32 | - static::deleting(function (self $student) { |
|
32 | + static::deleting(function(self $student) { |
|
33 | 33 | Attendance::where('student_id', $student->id)->delete(); |
34 | 34 | Enrollment::where('student_id', $student->id)->delete(); |
35 | 35 | }); |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | |
67 | 67 | return $this->hasMany(Attendance::class) |
68 | 68 | ->where('attendance_type_id', 4) // absence |
69 | - ->whereHas('event', function ($q) use ($period) { |
|
70 | - return $q->whereHas('course', function ($c) use ($period) { |
|
69 | + ->whereHas('event', function($q) use ($period) { |
|
70 | + return $q->whereHas('course', function($c) use ($period) { |
|
71 | 71 | return $c->where('period_id', $period->id); |
72 | 72 | }); |
73 | 73 | }); |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | return $this->hasMany(Attendance::class) |
83 | - ->whereHas('event', function ($q) use ($period) { |
|
84 | - return $q->whereHas('course', function ($c) use ($period) { |
|
83 | + ->whereHas('event', function($q) use ($period) { |
|
84 | + return $q->whereHas('course', function($c) use ($period) { |
|
85 | 85 | return $c->where('period_id', $period->id); |
86 | 86 | }); |
87 | 87 | }); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | public function getIsEnrolledAttribute() |
174 | 174 | { |
175 | 175 | // if the student is currently enrolled |
176 | - if ($this->enrollments()->whereHas('course', function ($q) { |
|
176 | + if ($this->enrollments()->whereHas('course', function($q) { |
|
177 | 177 | return $q->where('period_id', Period::get_default_period()->id); |
178 | 178 | })->count() > 0) { |
179 | 179 | return 1; |