@@ -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'); |
@@ -196,15 +196,15 @@ |
||
196 | 196 | |
197 | 197 | public function handle() |
198 | 198 | { |
199 | - Student::whereNull('gender_id')->chunkById(10, function ($students) { |
|
200 | - $query = $students->map(fn ($student) => ['id' => $student->id, 'name' => $this->remove_accents(strtok($student->firstname, ' '))]); |
|
199 | + Student::whereNull('gender_id')->chunkById(10, function($students) { |
|
200 | + $query = $students->map(fn($student) => ['id' => $student->id, 'name' => $this->remove_accents(strtok($student->firstname, ' '))]); |
|
201 | 201 | |
202 | 202 | $response = Http::get('https://api.genderize.io/?name[]='.$query->pluck('name')->implode('&name[]=')); |
203 | 203 | foreach ($students as $student) { |
204 | 204 | $firstname = $query->firstWhere('id', $student->id)['name']; |
205 | 205 | |
206 | 206 | $student->update([ |
207 | - 'gender_id' => match ($response->collect()->where('name', $firstname)->where('probability', '>', 0.9)->where('count', '>', 10)->first()['gender'] ?? '-') { |
|
207 | + 'gender_id' => match($response->collect()->where('name', $firstname)->where('probability', '>', 0.9)->where('count', '>', 10)->first()['gender'] ?? '-') { |
|
208 | 208 | 'male' => 2, |
209 | 209 | 'female' => 1, |
210 | 210 | default => null, |
@@ -15,7 +15,7 @@ |
||
15 | 15 | |
16 | 16 | public function styling() |
17 | 17 | { |
18 | - return match ($this->id) { |
|
18 | + return match($this->id) { |
|
19 | 19 | 1 => 'warning', |
20 | 20 | 2 => 'info', |
21 | 21 | default => 'danger', |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | { |
25 | 25 | parent::boot(); |
26 | 26 | |
27 | - static::addGlobalScope('order', function (Builder $builder) { |
|
27 | + static::addGlobalScope('order', function(Builder $builder) { |
|
28 | 28 | $builder->orderBy('year_id')->orderBy('order')->orderBy('id'); |
29 | 29 | }); |
30 | 30 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | ->where('courses.period_id', $this->id) |
155 | 155 | ->where('enrollments.deleted_at', null) |
156 | 156 | ->where('enrollments.parent_id', null) |
157 | - ->where(function ($query) { |
|
157 | + ->where(function($query) { |
|
158 | 158 | return $query->where('students.gender_id', 0)->orWhereNull('students.gender_id'); |
159 | 159 | }) |
160 | 160 | ->whereIn('enrollments.status_id', ['1', '2']) // filter out cancelled enrollments, todo make this configurable. |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | { |
202 | 202 | $period = self::where('id', '<', $this->id)->orderBy('id', 'desc')->first(); |
203 | 203 | |
204 | - if (! $period == null) { |
|
204 | + if (!$period == null) { |
|
205 | 205 | return $period; |
206 | 206 | } else { |
207 | 207 | return self::first(); |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | public function getCoursesWithPendingAttendanceAttribute() |
282 | 282 | { |
283 | 283 | // get all courses for period and preload relations |
284 | - $courses = $this->courses()->where(function ($query) { |
|
284 | + $courses = $this->courses()->where(function($query) { |
|
285 | 285 | $query->where('exempt_attendance', '!=', true); |
286 | 286 | $query->where('exempt_attendance', '!=', 1); |
287 | 287 | $query->orWhereNull('exempt_attendance'); |
@@ -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 | |
@@ -61,15 +61,15 @@ discard block |
||
61 | 61 | 4 => $query |
62 | 62 | ->where('lead_type_id', $leadTypeId) |
63 | 63 | ->orWhere( |
64 | - function ($query) { |
|
64 | + function($query) { |
|
65 | 65 | $query |
66 | 66 | ->whereNull('lead_type_id') |
67 | - ->whereHas('enrollments', fn ($query) => $query |
|
68 | - ->whereHas('course', function ($q) { |
|
67 | + ->whereHas('enrollments', fn($query) => $query |
|
68 | + ->whereHas('course', function($q) { |
|
69 | 69 | $q->where('period_id', '!=', Period::get_default_period()->id); |
70 | 70 | })) |
71 | - ->whereDoesntHave('enrollments', fn ($query) => $query |
|
72 | - ->whereHas('course', function ($q) { |
|
71 | + ->whereDoesntHave('enrollments', fn($query) => $query |
|
72 | + ->whereHas('course', function($q) { |
|
73 | 73 | $q->where('period_id', Period::get_default_period()->id); |
74 | 74 | })); |
75 | 75 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | |
111 | 111 | return $this->hasMany(Attendance::class) |
112 | 112 | ->where('attendance_type_id', 4) // absence |
113 | - ->whereHas('event', fn ($q) => $q->whereHas('course', fn ($c) => $c->where('period_id', $period->id))); |
|
113 | + ->whereHas('event', fn($q) => $q->whereHas('course', fn($c) => $c->where('period_id', $period->id))); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | public function periodAttendance(Period $period = null) |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | } |
121 | 121 | |
122 | 122 | return $this->hasMany(Attendance::class) |
123 | - ->whereHas('event', fn ($q) => $q->whereHas('course', fn ($c) => $c->where('period_id', $period->id))); |
|
123 | + ->whereHas('event', fn($q) => $q->whereHas('course', fn($c) => $c->where('period_id', $period->id))); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | public function contacts() |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | |
182 | 182 | public function getEmailAttribute(): ?string |
183 | 183 | { |
184 | - return $this?->user?->email; |
|
184 | + return $this ? ->user ? ->email; |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | public function getNameAttribute(): string |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | public function getIsEnrolledAttribute() |
203 | 203 | { |
204 | 204 | // if the student is currently enrolled |
205 | - if ($this->enrollments()->whereHas('course', fn ($q) => $q->where('period_id', Period::get_default_period()->id))->count() > 0) { |
|
205 | + if ($this->enrollments()->whereHas('course', fn($q) => $q->where('period_id', Period::get_default_period()->id))->count() > 0) { |
|
206 | 206 | return 1; |
207 | 207 | } |
208 | 208 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | |
302 | 302 | public function getImageAttribute(): ?string |
303 | 303 | { |
304 | - return $this->getMedia('profile-picture')->last()?->getUrl('thumb'); |
|
304 | + return $this->getMedia('profile-picture')->last() ? ->getUrl('thumb'); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | public function setImageAttribute($value) |
@@ -46,7 +46,7 @@ |
||
46 | 46 | ->where('periods.year_id', $this->id) |
47 | 47 | ->whereIn('enrollments.status_id', ['1', '2']) // filter out cancelled enrollments, todo make this configurable. |
48 | 48 | ->where('enrollments.parent_id', null)->where('enrollments.deleted_at', null) |
49 | - ->where(function ($query) { |
|
49 | + ->where(function($query) { |
|
50 | 50 | return $query->where('students.gender_id', 0)->orWhereNull('students.gender_id'); |
51 | 51 | }) |
52 | 52 | ->distinct('student_id')->count('enrollments.student_id'); |
@@ -53,12 +53,12 @@ |
||
53 | 53 | |
54 | 54 | View::composer( |
55 | 55 | ['partials.create_new_contact', 'students.edit-contact'], |
56 | - function ($view) { |
|
56 | + function($view) { |
|
57 | 57 | $view->with('contact_types', ContactRelationship::all()); |
58 | 58 | } |
59 | 59 | ); |
60 | 60 | |
61 | - View::composer('partials.add_book_to_student', function ($view) { |
|
61 | + View::composer('partials.add_book_to_student', function($view) { |
|
62 | 62 | $view->with('books', Book::all()); |
63 | 63 | $view->with('statuses', EnrollmentStatusType::all()); |
64 | 64 | }); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | 'label' => __('Due Date'), |
51 | 51 | ], |
52 | 52 | false, |
53 | - function ($value) { // if the filter is active, apply these constraints |
|
53 | + function($value) { // if the filter is active, apply these constraints |
|
54 | 54 | $this->crud->addClause('where', 'date', '>=', Carbon::parse($value)->firstOfMonth()); |
55 | 55 | $this->crud->addClause('where', 'date', '<=', Carbon::parse($value)->lastOfMonth()); |
56 | 56 | } |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | { |
93 | 93 | $payment = Payment::findOrFail($id); |
94 | 94 | |
95 | - if (! backpack_user()->can('enrollments.edit')) { |
|
95 | + if (!backpack_user()->can('enrollments.edit')) { |
|
96 | 96 | abort(403); |
97 | 97 | } |
98 | 98 | |
99 | - if (! $payment->invoice) { |
|
99 | + if (!$payment->invoice) { |
|
100 | 100 | abort(404, 'No enrollment found for this payment'); |
101 | 101 | } |
102 | 102 |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | 'name' => 'id', |
106 | 106 | 'label' => 'ID', |
107 | 107 | 'wrapper' => [ |
108 | - 'element' => function ($crud, $column, $entry) { |
|
108 | + 'element' => function($crud, $column, $entry) { |
|
109 | 109 | return $entry->status_id > 2 ? 'del' : 'span'; |
110 | 110 | }, |
111 | 111 | ], |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | 'type' => 'text', |
117 | 117 | 'name' => 'student.idnumber', |
118 | 118 | 'wrapper' => [ |
119 | - 'element' => function ($crud, $column, $entry) { |
|
119 | + 'element' => function($crud, $column, $entry) { |
|
120 | 120 | return $entry->status_id > 2 ? 'del' : 'span'; |
121 | 121 | }, |
122 | 122 | ], |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | 'label' => __('Last Name'), |
130 | 130 | 'type' => 'relationship', |
131 | 131 | 'wrapper' => [ |
132 | - 'element' => function ($crud, $column, $entry) { |
|
132 | + 'element' => function($crud, $column, $entry) { |
|
133 | 133 | return $entry->status_id > 2 ? 'del' : 'span'; |
134 | 134 | }, |
135 | 135 | ], |
136 | - 'searchLogic' => function ($query, $column, $searchTerm) { |
|
137 | - $query->orWhereHas('student', function ($q) use ($searchTerm) { |
|
138 | - $q->whereHas('user', function ($q) use ($searchTerm) { |
|
136 | + 'searchLogic' => function($query, $column, $searchTerm) { |
|
137 | + $query->orWhereHas('student', function($q) use ($searchTerm) { |
|
138 | + $q->whereHas('user', function($q) use ($searchTerm) { |
|
139 | 139 | $q->where('lastname', 'like', '%'.$searchTerm.'%'); |
140 | 140 | }); |
141 | 141 | }); |
@@ -149,13 +149,13 @@ discard block |
||
149 | 149 | 'label' => __('First Name'), |
150 | 150 | 'type' => 'relationship', |
151 | 151 | 'wrapper' => [ |
152 | - 'element' => function ($crud, $column, $entry) { |
|
152 | + 'element' => function($crud, $column, $entry) { |
|
153 | 153 | return $entry->status_id > 2 ? 'del' : 'span'; |
154 | 154 | }, |
155 | 155 | ], |
156 | - 'searchLogic' => function ($query, $column, $searchTerm) { |
|
157 | - $query->orWhereHas('student', function ($q) use ($searchTerm) { |
|
158 | - $q->whereHas('user', function ($q) use ($searchTerm) { |
|
156 | + 'searchLogic' => function($query, $column, $searchTerm) { |
|
157 | + $query->orWhereHas('student', function($q) use ($searchTerm) { |
|
158 | + $q->whereHas('user', function($q) use ($searchTerm) { |
|
159 | 159 | $q->where('firstname', 'like', '%'.$searchTerm.'%'); |
160 | 160 | }); |
161 | 161 | }); |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | 'model' => EnrollmentStatusType::class, |
202 | 202 | 'wrapper' => [ |
203 | 203 | 'element' => 'span', |
204 | - 'class' => function ($crud, $column, $entry) { |
|
204 | + 'class' => function($crud, $column, $entry) { |
|
205 | 205 | return 'badge badge-pill badge-'.$entry->enrollmentStatus->styling(); |
206 | 206 | }, |
207 | 207 | ], |
@@ -258,8 +258,8 @@ discard block |
||
258 | 258 | 'type' => 'select2_multiple', |
259 | 259 | 'label'=> __('Status'), |
260 | 260 | ], |
261 | - fn () => EnrollmentStatusType::all()->pluck('name', 'id')->toArray(), |
|
262 | - function ($values) { |
|
261 | + fn() => EnrollmentStatusType::all()->pluck('name', 'id')->toArray(), |
|
262 | + function($values) { |
|
263 | 263 | foreach (json_decode($values, null, 512, JSON_THROW_ON_ERROR) as $value) { |
264 | 264 | CRUD::addClause('orWhere', 'status_id', $value); |
265 | 265 | } |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | 'name' => 'period_id', |
271 | 271 | 'type' => 'select2', |
272 | 272 | 'label'=> __('Period'), |
273 | - ], fn () => Period::all()->pluck('name', 'id')->toArray(), function ($value) { |
|
273 | + ], fn() => Period::all()->pluck('name', 'id')->toArray(), function($value) { |
|
274 | 274 | CRUD::addClause('period', $value); |
275 | 275 | }); |
276 | 276 | |
@@ -280,12 +280,12 @@ discard block |
||
280 | 280 | 'type' => 'select2', |
281 | 281 | 'label'=> __('Scholarship'), |
282 | 282 | ], |
283 | - fn () => Scholarship::all()->pluck('name', 'id')->toArray(), |
|
284 | - function ($value) { // if the filter is active |
|
283 | + fn() => Scholarship::all()->pluck('name', 'id')->toArray(), |
|
284 | + function($value) { // if the filter is active |
|
285 | 285 | if ($value == 'all') { |
286 | 286 | CRUD::addClause('whereHas', 'scholarships'); |
287 | 287 | } else { |
288 | - CRUD::addClause('whereHas', 'scholarships', function ($q) use ($value) { |
|
288 | + CRUD::addClause('whereHas', 'scholarships', function($q) use ($value) { |
|
289 | 289 | $q->where('scholarships.id', $value); |
290 | 290 | }); |
291 | 291 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | ->get(); |
306 | 306 | |
307 | 307 | // get related comments |
308 | - $comments = $enrollment->invoices->map(fn (Invoice $invoice) => $invoice->comments)->flatten()->concat($enrollment->comments); |
|
308 | + $comments = $enrollment->invoices->map(fn(Invoice $invoice) => $invoice->comments)->flatten()->concat($enrollment->comments); |
|
309 | 309 | |
310 | 310 | $scholarships = Scholarship::all(); |
311 | 311 | |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | 'model' => \App\Models\Course::class, |
337 | 337 | 'attribute' => 'name', |
338 | 338 | |
339 | - 'options' => (fn ($query) => $query->orderBy('level_id', 'ASC')->where('period_id', $this->crud->getCurrentEntry()->course->period_id)->get()), |
|
339 | + 'options' => (fn($query) => $query->orderBy('level_id', 'ASC')->where('period_id', $this->crud->getCurrentEntry()->course->period_id)->get()), |
|
340 | 340 | ]); |
341 | 341 | |
342 | 342 | CRUD::addField(array_merge([ |