| @@ -27,7 +27,7 @@ discard block | ||
| 27 | 27 | parent::boot(); | 
| 28 | 28 | |
| 29 | 29 | // when creating a new enrollment, also add past attendance | 
| 30 | -        static::created(function (self $enrollment) { | |
| 30 | +        static::created(function(self $enrollment) { | |
| 31 | 31 |              $events = $enrollment->course->events->where('start', '<', (new Carbon)->toDateString()); | 
| 32 | 32 |              foreach ($events as $event) { | 
| 33 | 33 | $event->attendance()->create([ | 
| @@ -58,11 +58,11 @@ discard block | ||
| 58 | 58 | public function scopeWithoutChildren($query) | 
| 59 | 59 |      { | 
| 60 | 60 | return $query | 
| 61 | -            ->where(function ($query) { | |
| 61 | +            ->where(function($query) { | |
| 62 | 62 |                  $query->whereDoesntHave('childrenEnrollments') | 
| 63 | 63 |                  ->where('parent_id', null); | 
| 64 | 64 | }) | 
| 65 | -            ->orWhere(function ($query) { | |
| 65 | +            ->orWhere(function($query) { | |
| 66 | 66 |                  $query->where('parent_id', null); | 
| 67 | 67 | }) | 
| 68 | 68 | ->get(); | 
| @@ -84,7 +84,7 @@ discard block | ||
| 84 | 84 | |
| 85 | 85 | public function scopePeriod(Builder $query, $period) | 
| 86 | 86 |      { | 
| 87 | -        return $query->whereHas('course', function ($q) use ($period) { | |
| 87 | +        return $query->whereHas('course', function($q) use ($period) { | |
| 88 | 88 |              $q->where('period_id', $period); | 
| 89 | 89 | }); | 
| 90 | 90 | } | 
| @@ -294,13 +294,13 @@ discard block | ||
| 294 | 294 | |
| 295 | 295 | // delete attendance records related to the enrollment | 
| 296 | 296 |          $attendances = $this->course->attendance->where('student_id', $this->student->id); | 
| 297 | -        Attendance::destroy($attendances->map(function ($item, $key) { | |
| 297 | +        Attendance::destroy($attendances->map(function($item, $key) { | |
| 298 | 298 | return $item->id; | 
| 299 | 299 | })); | 
| 300 | 300 | |
| 301 | 301 |          foreach ($this->course->children as $child) { | 
| 302 | 302 |              $attendances = $child->attendance->where('student_id', $this->student->id); | 
| 303 | -            Attendance::destroy($attendances->map(function ($item, $key) { | |
| 303 | +            Attendance::destroy($attendances->map(function($item, $key) { | |
| 304 | 304 | return $item->id; | 
| 305 | 305 | })); | 
| 306 | 306 | } | 
| @@ -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(); | 
| @@ -17,7 +17,7 @@ | ||
| 17 | 17 | parent::boot(); | 
| 18 | 18 | |
| 19 | 19 | // before adding an event, we check that the teacher is available | 
| 20 | -        static::saving(function ($event) { | |
| 20 | +        static::saving(function($event) { | |
| 21 | 21 | $teacher = Teacher::find($event->teacher_id); | 
| 22 | 22 | // if the teacher is on leave on the day of the event | 
| 23 | 23 |              if ($event->teacher_id !== null && $teacher->leaves->contains('date', Carbon::parse($event->start)->toDateString())) { | 
| @@ -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'); | 
| @@ -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 | }); |