@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | |
43 | 43 | public function scopeEnrolled($query) |
44 | 44 | { |
45 | - return $query->whereHas('enrollments', function ($q) { |
|
46 | - return $q->whereHas('course', function ($q) { |
|
45 | + return $query->whereHas('enrollments', function($q) { |
|
46 | + return $q->whereHas('course', function($q) { |
|
47 | 47 | return $q->where('period_id', Period::get_default_period()->id); |
48 | 48 | }); |
49 | 49 | }); |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | |
52 | 52 | public function scopeComputedLeadType($query, $leadTypeId) |
53 | 53 | { |
54 | - return match ($leadTypeId) { |
|
55 | - 1 => $query->whereHas('enrollments', fn ($query) => $query->whereHas('course', function ($q) { |
|
54 | + return match($leadTypeId) { |
|
55 | + 1 => $query->whereHas('enrollments', fn($query) => $query->whereHas('course', function($q) { |
|
56 | 56 | $q->where('period_id', Period::get_default_period()->id); |
57 | 57 | })), |
58 | 58 | |
@@ -60,15 +60,15 @@ discard block |
||
60 | 60 | |
61 | 61 | 4 => $query |
62 | 62 | ->where('lead_type_id', $leadTypeId) |
63 | - ->orWhere(function ($query) { |
|
63 | + ->orWhere(function($query) { |
|
64 | 64 | $query |
65 | 65 | ->whereNull('lead_type_id') |
66 | - ->whereHas('enrollments', fn ($query) => $query |
|
67 | - ->whereHas('course', function ($q) { |
|
66 | + ->whereHas('enrollments', fn($query) => $query |
|
67 | + ->whereHas('course', function($q) { |
|
68 | 68 | $q->where('period_id', '!=', Period::get_default_period()->id); |
69 | 69 | })) |
70 | - ->whereDoesntHave('enrollments', fn ($query) => $query |
|
71 | - ->whereHas('course', function ($q) { |
|
70 | + ->whereDoesntHave('enrollments', fn($query) => $query |
|
71 | + ->whereHas('course', function($q) { |
|
72 | 72 | $q->where('period_id', Period::get_default_period()->id); |
73 | 73 | })); |
74 | 74 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | |
110 | 110 | return $this->hasMany(Attendance::class) |
111 | 111 | ->where('attendance_type_id', 4) // absence |
112 | - ->whereHas('event', fn ($q) => $q->whereHas('course', fn ($c) => $c->where('period_id', $period->id))); |
|
112 | + ->whereHas('event', fn($q) => $q->whereHas('course', fn($c) => $c->where('period_id', $period->id))); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | public function periodAttendance(Period $period = null) |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | } |
120 | 120 | |
121 | 121 | return $this->hasMany(Attendance::class) |
122 | - ->whereHas('event', fn ($q) => $q->whereHas('course', fn ($c) => $c->where('period_id', $period->id))); |
|
122 | + ->whereHas('event', fn($q) => $q->whereHas('course', fn($c) => $c->where('period_id', $period->id))); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | public function contacts() |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | |
181 | 181 | public function getEmailAttribute(): ?string |
182 | 182 | { |
183 | - return $this?->user?->email; |
|
183 | + return $this ? ->user ? ->email; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | public function getNameAttribute(): string |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | |
191 | 191 | public function getStudentAgeAttribute() |
192 | 192 | { |
193 | - return $this->birthdate ? Carbon::parse($this->birthdate)->age . ' ' . __('years old') : ''; |
|
193 | + return $this->birthdate ? Carbon::parse($this->birthdate)->age.' '.__('years old') : ''; |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | public function getStudentBirthdateAttribute() |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | public function getIsEnrolledAttribute() |
202 | 202 | { |
203 | 203 | // if the student is currently enrolled |
204 | - if ($this->enrollments()->whereHas('course', fn ($q) => $q->where('period_id', Period::get_default_period()->id))->count() > 0) { |
|
204 | + if ($this->enrollments()->whereHas('course', fn($q) => $q->where('period_id', Period::get_default_period()->id))->count() > 0) { |
|
205 | 205 | return 1; |
206 | 206 | } |
207 | 207 | |
@@ -296,13 +296,13 @@ discard block |
||
296 | 296 | |
297 | 297 | public function getImageAttribute(): ?string |
298 | 298 | { |
299 | - return $this->getMedia('profile-picture')->last()?->getUrl('thumb'); |
|
299 | + return $this->getMedia('profile-picture')->last() ? ->getUrl('thumb'); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | public function setImageAttribute($value) |
303 | 303 | { |
304 | 304 | // if the image was erased |
305 | - if ($value==null) { |
|
305 | + if ($value == null) { |
|
306 | 306 | $this->clearMediaCollection('profile-picture'); |
307 | 307 | } |
308 | 308 |