@@ -71,7 +71,7 @@ |
||
| 71 | 71 | |
| 72 | 72 | // persist the products |
| 73 | 73 | foreach ($request->products as $f => $product) { |
| 74 | - $productType = match ($product['type']) { |
|
| 74 | + $productType = match($product['type']) { |
|
| 75 | 75 | 'enrollment' => Enrollment::class, |
| 76 | 76 | 'scheduledPayment' => Enrollment::class, |
| 77 | 77 | 'fee' => Fee::class, |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | $events = Event::with('course') |
| 26 | 26 | ->where('start', '>', Carbon::now()->subDays(30))->where('end', '<', Carbon::now()->addDays(30))->orderBy('id', 'desc') // TODO optimize this. |
| 27 | 27 | ->get() |
| 28 | - ->map(fn ($event) => [ |
|
| 28 | + ->map(fn($event) => [ |
|
| 29 | 29 | 'title' => $event['name'] ?? '', |
| 30 | 30 | 'resourceId' => $event['teacher_id'], |
| 31 | 31 | 'start' => $event['start'], |
@@ -37,14 +37,14 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | $teachers = Teacher::all()->toArray(); |
| 39 | 39 | |
| 40 | - $teachers = array_map(fn ($teacher) => [ |
|
| 40 | + $teachers = array_map(fn($teacher) => [ |
|
| 41 | 41 | 'id' => $teacher['id'], |
| 42 | 42 | 'title' => $teacher['name'] ?? '', |
| 43 | 43 | ], $teachers); |
| 44 | 44 | |
| 45 | 45 | array_push($teachers, ['id' => 'tbd', 'title' => 'Unassigned']); |
| 46 | 46 | |
| 47 | - $unassigned_events = Event::unassigned()->get()->map(fn ($event) => [ |
|
| 47 | + $unassigned_events = Event::unassigned()->get()->map(fn($event) => [ |
|
| 48 | 48 | 'title' => $event['name'] ?? '', |
| 49 | 49 | 'resourceId' => 'tbd', |
| 50 | 50 | 'start' => $event['start'], |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | 'borderColor' => $event['color'], |
| 55 | 55 | ]); |
| 56 | 56 | |
| 57 | - $leaves = Leave::orderBy('date', 'desc')->limit(10000)->get()->map(fn ($event) => [ |
|
| 57 | + $leaves = Leave::orderBy('date', 'desc')->limit(10000)->get()->map(fn($event) => [ |
|
| 58 | 58 | 'title' => $event->leaveType->name ?? 'ABS', // todo fix |
| 59 | 59 | 'resourceId' => $event['teacher_id'], |
| 60 | 60 | 'start' => $event['date'], |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | abort(403); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - $events = $teacher->events->map(fn ($event) => [ |
|
| 83 | + $events = $teacher->events->map(fn($event) => [ |
|
| 84 | 84 | 'title' => $event['name'], |
| 85 | 85 | 'start' => $event['start'], |
| 86 | 86 | 'end' => $event['end'], |
@@ -88,8 +88,8 @@ discard block |
||
| 88 | 88 | 'borderColor' => $event['color'], |
| 89 | 89 | ]); |
| 90 | 90 | |
| 91 | - $leaves = $teacher->leaves->map(fn ($event) => [ |
|
| 92 | - 'title' => $event->leaveType->name ?? 'vacances', // todo fix |
|
| 91 | + $leaves = $teacher->leaves->map(fn($event) => [ |
|
| 92 | + 'title' => $event->leaveType->name ?? 'vacances', // todo fix |
|
| 93 | 93 | 'start' => $event['date'], |
| 94 | 94 | 'allDay' => true, |
| 95 | 95 | ]); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | public function teacher(Request $request) |
| 46 | 46 | { |
| 47 | - if (! backpack_user()->isTeacher()) { |
|
| 47 | + if (!backpack_user()->isTeacher()) { |
|
| 48 | 48 | abort(403); |
| 49 | 49 | } |
| 50 | 50 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | public function student() |
| 71 | 71 | { |
| 72 | - if (! backpack_user()->isStudent()) { |
|
| 72 | + if (!backpack_user()->isStudent()) { |
|
| 73 | 73 | abort(403); |
| 74 | 74 | } |
| 75 | 75 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | $currentPeriod = Period::get_default_period(); |
| 88 | 88 | $enrollmentsPeriod = Period::get_enrollments_period(); |
| 89 | 89 | |
| 90 | - if (! backpack_user()->hasRole(['admin', 'secretary'])) { |
|
| 90 | + if (!backpack_user()->hasRole(['admin', 'secretary'])) { |
|
| 91 | 91 | abort(403); |
| 92 | 92 | } |
| 93 | 93 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | // todo optimize this !! |
| 97 | 97 | $events = Event::where('start', '>', Carbon::now()->subDays(15))->where('end', '<', Carbon::now()->addDays(15))->orderBy('id', 'desc') |
| 98 | 98 | ->get() |
| 99 | - ->map(fn ($event) => [ |
|
| 99 | + ->map(fn($event) => [ |
|
| 100 | 100 | 'title' => $event['name'], |
| 101 | 101 | 'resourceId' => $event['teacher_id'], |
| 102 | 102 | 'start' => $event['start'], |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | $teachers = Teacher::with('user')->get()->toArray(); |
| 110 | 110 | |
| 111 | - $teachers = array_map(fn ($teacher) => [ |
|
| 111 | + $teachers = array_map(fn($teacher) => [ |
|
| 112 | 112 | 'id' => $teacher['id'], |
| 113 | 113 | 'title' => $teacher['user']['firstname'], |
| 114 | 114 | ], $teachers); |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | 'total_enrollment_count' => $currentPeriod->internal_enrollments_count, |
| 123 | 123 | 'resources' => $teachers, |
| 124 | 124 | 'events' => $events, |
| 125 | - 'pending_attendance' => $currentPeriod->courses_with_pending_attendance, // todo: optimize |
|
| 125 | + 'pending_attendance' => $currentPeriod->courses_with_pending_attendance, // todo: optimize |
|
| 126 | 126 | 'unassigned_events' => Event::unassigned()->count(), |
| 127 | 127 | 'pending_leads' => LeadType::find(4)->students()->count(), |
| 128 | 128 | ]); |
@@ -68,7 +68,7 @@ |
||
| 68 | 68 | |
| 69 | 69 | $course = Course::with('evaluationType')->find($enrollment->course_id); |
| 70 | 70 | |
| 71 | - $skills = $course->skills->map(function ($skill, $key) use ($student_skills) { |
|
| 71 | + $skills = $course->skills->map(function($skill, $key) use ($student_skills) { |
|
| 72 | 72 | $skill['status'] = $student_skills->where('skill_id', $skill->id)->first()->skill_scale_id ?? null; |
| 73 | 73 | |
| 74 | 74 | return $skill; |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | parent::boot(); |
| 22 | 22 | |
| 23 | 23 | // before adding an event, we check that the teacher is available |
| 24 | - static::saving(function ($event) { |
|
| 24 | + static::saving(function($event) { |
|
| 25 | 25 | $teacher = Teacher::find($event->teacher_id); |
| 26 | 26 | // if the teacher is on leave on the day of the event |
| 27 | 27 | if ($event->teacher_id !== null && $teacher) { |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | public function getColorAttribute() |
| 150 | 150 | { |
| 151 | - return $this?->course->color ?? ('#'.substr(md5($this->course_id ?? '0'), 0, 6)); |
|
| 151 | + return $this ? ->course->color ?? ('#'.substr(md5($this->course_id ?? '0'), 0, 6)); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /* |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | */ |
| 204 | 204 | public function skills() |
| 205 | 205 | { |
| 206 | - return $this->evaluationType?->skills()->orderBy('order'); |
|
| 206 | + return $this->evaluationType ? ->skills()->orderBy('order'); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | public function books() |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | */ |
| 229 | 229 | public function getPendingAttendanceAttribute() |
| 230 | 230 | { |
| 231 | - $events = Event::where(function ($query) { |
|
| 231 | + $events = Event::where(function($query) { |
|
| 232 | 232 | $query->where('course_id', $this->id); |
| 233 | 233 | $query->where('exempt_attendance', '!=', true); |
| 234 | 234 | $query->where('exempt_attendance', '!=', 1); |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | foreach ($courseTimes as $courseTime) { |
| 362 | 362 | $initial = $daysInitials[$courseTime->day]; |
| 363 | 363 | |
| 364 | - if (! isset($parsedCourseTimes[$initial])) { |
|
| 364 | + if (!isset($parsedCourseTimes[$initial])) { |
|
| 365 | 365 | $parsedCourseTimes[$initial] = []; |
| 366 | 366 | } |
| 367 | 367 | |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | public function getCourseTeacherNameAttribute() |
| 409 | 409 | { |
| 410 | 410 | if ($this->teacher_id) { |
| 411 | - return $this->teacher?->name; |
|
| 411 | + return $this->teacher ? ->name; |
|
| 412 | 412 | } else { |
| 413 | 413 | return '-'; |
| 414 | 414 | } |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | |
| 442 | 442 | public function getAcceptsNewStudentsAttribute(): bool |
| 443 | 443 | { |
| 444 | - if (! $this->spots || $this->spots == 0) { |
|
| 444 | + if (!$this->spots || $this->spots == 0) { |
|
| 445 | 445 | return true; |
| 446 | 446 | } |
| 447 | 447 | |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | |
| 465 | 465 | public function eventsWithExpectedAttendance() |
| 466 | 466 | { |
| 467 | - return $this->events()->where(function ($query) { |
|
| 467 | + return $this->events()->where(function($query) { |
|
| 468 | 468 | $query->where('exempt_attendance', '!=', true); |
| 469 | 469 | $query->where('exempt_attendance', '!=', 1); |
| 470 | 470 | $query->orWhereNull('exempt_attendance'); |
@@ -104,7 +104,7 @@ |
||
| 104 | 104 | |
| 105 | 105 | public function getDisplayStatusAttribute() |
| 106 | 106 | { |
| 107 | - return match ($this->status) { |
|
| 107 | + return match($this->status) { |
|
| 108 | 108 | null, 1 => __('Pending'), |
| 109 | 109 | 2 => __('Paid'), |
| 110 | 110 | }; |
@@ -39,22 +39,22 @@ discard block |
||
| 39 | 39 | /** attributes */ |
| 40 | 40 | public function getFirstnameAttribute() : ?string |
| 41 | 41 | { |
| 42 | - return $this?->user?->firstname; |
|
| 42 | + return $this ? ->user ? ->firstname; |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | public function getLastnameAttribute() : ?string |
| 46 | 46 | { |
| 47 | - return $this?->user?->lastname; |
|
| 47 | + return $this ? ->user ? ->lastname; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | public function getEmailAttribute() : ?string |
| 51 | 51 | { |
| 52 | - return $this?->user?->email ?? ''; |
|
| 52 | + return $this ? ->user ? ->email ?? ''; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | public function getNameAttribute() : ?string |
| 56 | 56 | { |
| 57 | - return $this?->user?->firstname.' '.$this?->user?->lastname; |
|
| 57 | + return $this ? ->user ? ->firstname.' '.$this ? ->user ? ->lastname; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | public function period_courses(Period $period) |
@@ -178,14 +178,14 @@ discard block |
||
| 178 | 178 | $eventsWithMissingAttendance = []; |
| 179 | 179 | |
| 180 | 180 | $eventsWithExpectedAttendance = $this->events() |
| 181 | - ->where(function ($query) { |
|
| 181 | + ->where(function($query) { |
|
| 182 | 182 | $query->where('exempt_attendance', '!=', true); |
| 183 | 183 | $query->where('exempt_attendance', '!=', 1); |
| 184 | 184 | $query->orWhereNull('exempt_attendance'); |
| 185 | 185 | }) |
| 186 | 186 | ->where('course_id', '!=', null) |
| 187 | - ->whereHas('course', fn (Builder $query) => $query->where('period_id', $period->id) |
|
| 188 | - ->where(function ($query) { |
|
| 187 | + ->whereHas('course', fn(Builder $query) => $query->where('period_id', $period->id) |
|
| 188 | + ->where(function($query) { |
|
| 189 | 189 | $query->where('exempt_attendance', '!=', true); |
| 190 | 190 | $query->where('exempt_attendance', '!=', 1); |
| 191 | 191 | $query->orWhereNull('exempt_attendance'); |
@@ -27,6 +27,6 @@ |
||
| 27 | 27 | { |
| 28 | 28 | // if the student is enrolled in any class by the user |
| 29 | 29 | |
| 30 | - return $student->enrollments()->whereHas('course', fn ($q) => $q->where('teacher_id', $user->id))->count() > 0; |
|
| 30 | + return $student->enrollments()->whereHas('course', fn($q) => $q->where('teacher_id', $user->id))->count() > 0; |
|
| 31 | 31 | } |
| 32 | 32 | } |