@@ -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'); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | public function scopeStatus(Builder $query, $status) |
33 | 33 | { |
34 | - return match ($status) { |
|
34 | + return match($status) { |
|
35 | 35 | '2' => $query->where('status', 2), |
36 | 36 | '1' => $query->where('status', 1), |
37 | 37 | default => $query, |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | public function invoices() |
69 | 69 | { |
70 | - return $this->invoiceDetails->map(fn (InvoiceDetail $invoiceDetail) => $invoiceDetail->invoice)->filter(); |
|
70 | + return $this->invoiceDetails->map(fn(InvoiceDetail $invoiceDetail) => $invoiceDetail->invoice)->filter(); |
|
71 | 71 | } |
72 | 72 | /* |
73 | 73 | |-------------------------------------------------------------------------- |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | public function getStatusTypeNameAttribute() |
125 | 125 | { |
126 | - return match ($this->status) { |
|
126 | + return match($this->status) { |
|
127 | 127 | 2 => __('Paid'), |
128 | 128 | 1 => __('Pending'), |
129 | 129 | default => '-', |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | public function scopeWithoutChildren($query) |
61 | 61 | { |
62 | 62 | return $query |
63 | - ->where(function ($query) { |
|
63 | + ->where(function($query) { |
|
64 | 64 | $query->whereDoesntHave('childrenEnrollments') |
65 | 65 | ->where('parent_id', null); |
66 | 66 | }) |
67 | - ->orWhere(function ($query) { |
|
67 | + ->orWhere(function($query) { |
|
68 | 68 | $query->where('parent_id', null); |
69 | 69 | }) |
70 | 70 | ->get(); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | public function scopePeriod(Builder $query, int $periodId) |
88 | 88 | { |
89 | - return $query->whereHas('course', function ($q) use ($periodId) { |
|
89 | + return $query->whereHas('course', function($q) use ($periodId) { |
|
90 | 90 | $q->where('period_id', $periodId); |
91 | 91 | }); |
92 | 92 | } |
@@ -174,13 +174,13 @@ discard block |
||
174 | 174 | |
175 | 175 | public function invoices() |
176 | 176 | { |
177 | - return $this->invoiceDetails->map(fn (InvoiceDetail $invoiceDetail) => $invoiceDetail->invoice)->filter(); |
|
177 | + return $this->invoiceDetails->map(fn(InvoiceDetail $invoiceDetail) => $invoiceDetail->invoice)->filter(); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | // also includes invoices for this enrollment's scheduled payments. |
181 | 181 | public function relatedInvoices() |
182 | 182 | { |
183 | - $scheduledPaymentsInvoices = $this->scheduledPayments->map(fn (ScheduledPayment $scheduledPayment) => $scheduledPayment->invoices()); |
|
183 | + $scheduledPaymentsInvoices = $this->scheduledPayments->map(fn(ScheduledPayment $scheduledPayment) => $scheduledPayment->invoices()); |
|
184 | 184 | |
185 | 185 | return $this->invoices()->concat($scheduledPaymentsInvoices)->flatten(1); |
186 | 186 | } |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | } |
337 | 337 | |
338 | 338 | // if enabled, retrieve the default price category for the student |
339 | - if (config('invoicing.price_categories_enabled') && $this->student?->price_category) { |
|
339 | + if (config('invoicing.price_categories_enabled') && $this->student ? ->price_category) { |
|
340 | 340 | $price_category = $this->student->price_category; |
341 | 341 | |
342 | 342 | return $this->course->$price_category ?? 0; |
@@ -366,11 +366,11 @@ discard block |
||
366 | 366 | |
367 | 367 | // delete attendance records related to the enrollment |
368 | 368 | $attendances = $this->course->attendance->where('student_id', $this->student->id); |
369 | - Attendance::destroy($attendances->map(fn ($item, $key) => $item->id)); |
|
369 | + Attendance::destroy($attendances->map(fn($item, $key) => $item->id)); |
|
370 | 370 | |
371 | 371 | foreach ($this->course->children as $child) { |
372 | 372 | $attendances = $child->attendance->where('student_id', $this->student->id); |
373 | - Attendance::destroy($attendances->map(fn ($item, $key) => $item->id)); |
|
373 | + Attendance::destroy($attendances->map(fn($item, $key) => $item->id)); |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | $this->delete(); |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | } |
402 | 402 | |
403 | 403 | // if one book is expired |
404 | - if ($this->student && $this->student->books->where('id', $book->id)->filter(fn ($book) => $book->pivot->expiry_date == null || $book->pivot->expiry_date > Carbon::now())->count() == 0) { |
|
404 | + if ($this->student && $this->student->books->where('id', $book->id)->filter(fn($book) => $book->pivot->expiry_date == null || $book->pivot->expiry_date > Carbon::now())->count() == 0) { |
|
405 | 405 | return 'EXP'; |
406 | 406 | } |
407 | 407 | } |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | |
413 | 413 | public function getBalanceAttribute() |
414 | 414 | { |
415 | - if (! config('invoicing.invoices_contain_enrollments_only')) { |
|
415 | + if (!config('invoicing.invoices_contain_enrollments_only')) { |
|
416 | 416 | abort(422, 'Configuration options forbid to access this value'); |
417 | 417 | } |
418 | 418 |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | |
46 | 46 | public function scopeEnrolled($query) |
47 | 47 | { |
48 | - return $query->whereHas('enrollments', function ($q) { |
|
49 | - return $q->whereHas('course', function ($q) { |
|
48 | + return $query->whereHas('enrollments', function($q) { |
|
49 | + return $q->whereHas('course', function($q) { |
|
50 | 50 | return $q->where('period_id', Period::get_default_period()->id); |
51 | 51 | }); |
52 | 52 | }); |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | |
55 | 55 | public function scopeComputedLeadType($query, $leadTypeId) |
56 | 56 | { |
57 | - return match ($leadTypeId) { |
|
58 | - 1 => $query->whereHas('enrollments', fn ($query) => $query->whereHas('course', function ($q) { |
|
57 | + return match($leadTypeId) { |
|
58 | + 1 => $query->whereHas('enrollments', fn($query) => $query->whereHas('course', function($q) { |
|
59 | 59 | $q->where('period_id', Period::get_default_period()->id); |
60 | 60 | })), |
61 | 61 | |
@@ -64,15 +64,15 @@ discard block |
||
64 | 64 | 4 => $query |
65 | 65 | ->where('lead_type_id', $leadTypeId) |
66 | 66 | ->orWhere( |
67 | - function ($query) { |
|
67 | + function($query) { |
|
68 | 68 | $query |
69 | 69 | ->whereNull('lead_type_id') |
70 | - ->whereHas('enrollments', fn ($query) => $query |
|
71 | - ->whereHas('course', function ($q) { |
|
70 | + ->whereHas('enrollments', fn($query) => $query |
|
71 | + ->whereHas('course', function($q) { |
|
72 | 72 | $q->where('period_id', '!=', Period::get_default_period()->id); |
73 | 73 | })) |
74 | - ->whereDoesntHave('enrollments', fn ($query) => $query |
|
75 | - ->whereHas('course', function ($q) { |
|
74 | + ->whereDoesntHave('enrollments', fn($query) => $query |
|
75 | + ->whereHas('course', function($q) { |
|
76 | 76 | $q->where('period_id', Period::get_default_period()->id); |
77 | 77 | })); |
78 | 78 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | |
114 | 114 | return $this->hasMany(Attendance::class) |
115 | 115 | ->where('attendance_type_id', 4) // absence |
116 | - ->whereHas('event', fn ($q) => $q->whereHas('course', fn ($c) => $c->where('period_id', $period->id))); |
|
116 | + ->whereHas('event', fn($q) => $q->whereHas('course', fn($c) => $c->where('period_id', $period->id))); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | public function periodAttendance(Period $period = null) |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | } |
124 | 124 | |
125 | 125 | return $this->hasMany(Attendance::class) |
126 | - ->whereHas('event', fn ($q) => $q->whereHas('course', fn ($c) => $c->where('period_id', $period->id))); |
|
126 | + ->whereHas('event', fn($q) => $q->whereHas('course', fn($c) => $c->where('period_id', $period->id))); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | public function contacts() |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | |
185 | 185 | public function getEmailAttribute(): ?string |
186 | 186 | { |
187 | - return $this?->user?->email; |
|
187 | + return $this ? ->user ? ->email; |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | public function getNameAttribute(): string |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | public function getIsEnrolledAttribute() |
206 | 206 | { |
207 | 207 | // if the student is currently enrolled |
208 | - if ($this->enrollments()->whereHas('course', fn ($q) => $q->where('period_id', Period::get_default_period()->id))->count() > 0) { |
|
208 | + if ($this->enrollments()->whereHas('course', fn($q) => $q->where('period_id', Period::get_default_period()->id))->count() > 0) { |
|
209 | 209 | return 1; |
210 | 210 | } |
211 | 211 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | |
305 | 305 | public function getImageAttribute(): ?string |
306 | 306 | { |
307 | - return $this->getMedia('profile-picture')->last()?->getUrl('thumb'); |
|
307 | + return $this->getMedia('profile-picture')->last() ? ->getUrl('thumb'); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | public function setImageAttribute($value) |
@@ -349,8 +349,8 @@ discard block |
||
349 | 349 | |
350 | 350 | public function handle() |
351 | 351 | { |
352 | - Student::whereNull('gender_id')->chunkById(10, function ($students) { |
|
353 | - $query = $students->map(fn ($student) => ['id' => $student->id, |
|
352 | + Student::whereNull('gender_id')->chunkById(10, function($students) { |
|
353 | + $query = $students->map(fn($student) => ['id' => $student->id, |
|
354 | 354 | 'name' => $this->remove_accents(strtok($student->firstname, ' ')), ]); |
355 | 355 | |
356 | 356 | $response = Http::get('https://api.genderize.io/?name[]='.$query->pluck('name')->implode('&name[]=')); |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | $firstname = $query->firstWhere('id', $student->id)['name']; |
359 | 359 | |
360 | 360 | $student->update([ |
361 | - 'gender_id' => match ($response->collect()->where('name', $firstname)->where('probability', '>', 0.9)->where('count', '>', 10)->first()['gender'] ?? '-') { |
|
361 | + 'gender_id' => match($response->collect()->where('name', $firstname)->where('probability', '>', 0.9)->where('count', '>', 10)->first()['gender'] ?? '-') { |
|
362 | 362 | 'male' => 2, |
363 | 363 | 'female' => 1, |
364 | 364 | default => null, |
@@ -30,70 +30,70 @@ |
||
30 | 30 | * a user is allowed to edit the course grades if they are the teacher for this course, |
31 | 31 | * or if they have explicit permission to do so |
32 | 32 | */ |
33 | - Gate::define('edit-course-grades', fn ($user, $course) => $user->isTeacher() && $user->id == $course->teacher_id || $user->can('evaluation.edit')); |
|
33 | + Gate::define('edit-course-grades', fn($user, $course) => $user->isTeacher() && $user->id == $course->teacher_id || $user->can('evaluation.edit')); |
|
34 | 34 | |
35 | 35 | /* |
36 | 36 | * a user is allowed to view the course attendance sheet if they are the teacher for this course, |
37 | 37 | * or if they have explicit permission to view all course attendance sheets |
38 | 38 | */ |
39 | - Gate::define('view-course-attendance', fn ($user, $course) => $user->isTeacher() && $user->id == $course->teacher_id || $user->can('attendance.view')); |
|
39 | + Gate::define('view-course-attendance', fn($user, $course) => $user->isTeacher() && $user->id == $course->teacher_id || $user->can('attendance.view')); |
|
40 | 40 | |
41 | 41 | /* |
42 | 42 | * a user is allowed to view the event attendance sheet if they are the teacher for this event, |
43 | 43 | * if they are the teacher for this course, |
44 | 44 | * or if they have explicit permission to view all event attendance sheets |
45 | 45 | */ |
46 | - Gate::define('view-event-attendance', fn ($user, $event) => ($event->teacher_id == $user->id) || ($event->course->teacher_id == $user->id) || $user->can('attendance.view')); |
|
46 | + Gate::define('view-event-attendance', fn($user, $event) => ($event->teacher_id == $user->id) || ($event->course->teacher_id == $user->id) || $user->can('attendance.view')); |
|
47 | 47 | |
48 | 48 | /* |
49 | 49 | * a user is allowed to edit an attendance sheet if they are the teacher for the event, |
50 | 50 | * if they are the teacher for the course, |
51 | 51 | * or if they have explicit permission to edit any attendance sheets |
52 | 52 | */ |
53 | - Gate::define('edit-attendance', fn ($user, $event) => ($event->teacher_id == $user->id) || ($event->course->teacher_id == $user->id) || $user->can('attendance.edit')); |
|
53 | + Gate::define('edit-attendance', fn($user, $event) => ($event->teacher_id == $user->id) || ($event->course->teacher_id == $user->id) || $user->can('attendance.edit')); |
|
54 | 54 | |
55 | 55 | /* |
56 | 56 | * teachers are allowed to view their own calendar, |
57 | 57 | * and users with explicit permission can view all calendars |
58 | 58 | */ |
59 | - Gate::define('view-teacher-calendar', fn ($user, $teacher) => ($user->isTeacher() && $user->id == $teacher->id) || $user->can('calendars.view')); |
|
59 | + Gate::define('view-teacher-calendar', fn($user, $teacher) => ($user->isTeacher() && $user->id == $teacher->id) || $user->can('calendars.view')); |
|
60 | 60 | |
61 | 61 | /* |
62 | 62 | * teachers are allowed to view their own courses, |
63 | 63 | * and users with explicit permission can view all courses |
64 | 64 | */ |
65 | - Gate::define('view-course', fn ($user, Course $course) => ($user->isTeacher() && $user->id == $course->teacher_id) || $user->can('courses.view')); |
|
65 | + Gate::define('view-course', fn($user, Course $course) => ($user->isTeacher() && $user->id == $course->teacher_id) || $user->can('courses.view')); |
|
66 | 66 | |
67 | 67 | /* |
68 | 68 | * the user is allowed to view the result if they are the student, |
69 | 69 | * if they are a teacher |
70 | 70 | * of if they have explicit permission to view any result |
71 | 71 | */ |
72 | - Gate::define('view-enrollment', fn ($user, $enrollment) => ($user->isStudent() && $user->id == $enrollment->student_id) || $user->isTeacher() || $user->can('evaluation.view')); |
|
72 | + Gate::define('view-enrollment', fn($user, $enrollment) => ($user->isStudent() && $user->id == $enrollment->student_id) || $user->isTeacher() || $user->can('evaluation.view')); |
|
73 | 73 | |
74 | 74 | /* |
75 | 75 | * if the user is the teacher of the course |
76 | 76 | * of if they have explicit permission to enroll students |
77 | 77 | */ |
78 | - Gate::define('enroll-in-course', fn ($user, $course) => $course->teacher_id == $user->id || $user->can('enrollments.edit')); |
|
78 | + Gate::define('enroll-in-course', fn($user, $course) => $course->teacher_id == $user->id || $user->can('enrollments.edit')); |
|
79 | 79 | |
80 | 80 | /* |
81 | 81 | * if the user is a teacher |
82 | 82 | * of if they have explicit permission to enroll students |
83 | 83 | */ |
84 | - Gate::define('enroll-students', fn ($user) => $user->isTeacher() || $user->can('enrollments.edit')); |
|
84 | + Gate::define('enroll-students', fn($user) => $user->isTeacher() || $user->can('enrollments.edit')); |
|
85 | 85 | |
86 | 86 | /* |
87 | 87 | * teachers are allowed to view their own hours, |
88 | 88 | * and users with explicit permission can view all hours |
89 | 89 | */ |
90 | - Gate::define('view-teacher-hours', fn ($user, $teacher) => ($user->isTeacher() && $user->id == $teacher->id) || $user->can('hr.view')); |
|
90 | + Gate::define('view-teacher-hours', fn($user, $teacher) => ($user->isTeacher() && $user->id == $teacher->id) || $user->can('hr.view')); |
|
91 | 91 | |
92 | 92 | /* |
93 | 93 | * teachers are allowed to edit results for their own students |
94 | 94 | * as well as users with explicit permission to edit any result |
95 | 95 | */ |
96 | - Gate::define('edit-result', function ($user, $enrollment) { |
|
96 | + Gate::define('edit-result', function($user, $enrollment) { |
|
97 | 97 | if ($user->can('evaluation.edit')) { |
98 | 98 | return true; |
99 | 99 | } |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | |
98 | 98 | CRUD::addColumns([['name' => 'id', |
99 | 99 | 'label' => 'ID', |
100 | - 'wrapper' => ['element' => function ($crud, $column, $entry) { |
|
100 | + 'wrapper' => ['element' => function($crud, $column, $entry) { |
|
101 | 101 | return $entry->status_id > 2 ? 'del' : 'span'; |
102 | 102 | }], ], |
103 | 103 | |
104 | 104 | ['label' => __('ID number'), |
105 | 105 | 'type' => 'text', |
106 | 106 | 'name' => 'student.idnumber', |
107 | - 'wrapper' => ['element' => function ($crud, $column, $entry) { |
|
107 | + 'wrapper' => ['element' => function($crud, $column, $entry) { |
|
108 | 108 | return $entry->status_id > 2 ? 'del' : 'span'; |
109 | 109 | }], ], |
110 | 110 | |
@@ -113,17 +113,17 @@ discard block |
||
113 | 113 | 'attribute' => 'lastname', |
114 | 114 | 'label' => __('Last Name'), |
115 | 115 | 'type' => 'relationship', |
116 | - 'wrapper' => ['element' => function ($crud, $column, $entry) { |
|
116 | + 'wrapper' => ['element' => function($crud, $column, $entry) { |
|
117 | 117 | return $entry->status_id > 2 ? 'del' : 'span'; |
118 | 118 | }], |
119 | 119 | 'orderable' => true, |
120 | - 'orderLogic' => function ($query, $column, $columnDirection) { |
|
120 | + 'orderLogic' => function($query, $column, $columnDirection) { |
|
121 | 121 | return $query->leftJoin('users', 'enrollments.student_id', '=', 'users.id') |
122 | 122 | ->orderBy('users.lastname', $columnDirection)->select('enrollments.*'); |
123 | 123 | }, |
124 | - 'searchLogic' => function ($query, $column, $searchTerm) { |
|
125 | - $query->orWhereHas('student', function ($q) use ($searchTerm) { |
|
126 | - $q->whereHas('user', function ($q) use ($searchTerm) { |
|
124 | + 'searchLogic' => function($query, $column, $searchTerm) { |
|
125 | + $query->orWhereHas('student', function($q) use ($searchTerm) { |
|
126 | + $q->whereHas('user', function($q) use ($searchTerm) { |
|
127 | 127 | $q->where('lastname', 'like', '%'.$searchTerm.'%'); |
128 | 128 | }); |
129 | 129 | }); |
@@ -135,17 +135,17 @@ discard block |
||
135 | 135 | 'attribute' => 'firstname', |
136 | 136 | 'label' => __('First Name'), |
137 | 137 | 'type' => 'relationship', |
138 | - 'wrapper' => ['element' => function ($crud, $column, $entry) { |
|
138 | + 'wrapper' => ['element' => function($crud, $column, $entry) { |
|
139 | 139 | return $entry->status_id > 2 ? 'del' : 'span'; |
140 | 140 | }], |
141 | - 'searchLogic' => function ($query, $column, $searchTerm) { |
|
142 | - $query->orWhereHas('student', function ($q) use ($searchTerm) { |
|
143 | - $q->whereHas('user', function ($q) use ($searchTerm) { |
|
141 | + 'searchLogic' => function($query, $column, $searchTerm) { |
|
142 | + $query->orWhereHas('student', function($q) use ($searchTerm) { |
|
143 | + $q->whereHas('user', function($q) use ($searchTerm) { |
|
144 | 144 | $q->where('firstname', 'like', '%'.$searchTerm.'%'); |
145 | 145 | }); |
146 | 146 | }); |
147 | 147 | }, |
148 | - 'orderLogic' => function ($query, $column, $columnDirection) { |
|
148 | + 'orderLogic' => function($query, $column, $columnDirection) { |
|
149 | 149 | return $query->leftJoin('users', 'enrollments.student_id', '=', 'users.id') |
150 | 150 | ->orderBy('users.firstname', $columnDirection)->select('enrollments.*'); |
151 | 151 | }, |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | 'name' => 'course.period', |
170 | 170 | 'label' => __('Period'), |
171 | 171 | 'attribute' => 'name', |
172 | - 'orderLogic' => function ($query, $column, $columnDirection) { |
|
172 | + 'orderLogic' => function($query, $column, $columnDirection) { |
|
173 | 173 | return $query->leftJoin('courses', 'enrollments.course_id', '=', 'courses.id') |
174 | 174 | ->orderBy('courses.period_id', $columnDirection)->select('enrollments.*'); |
175 | 175 | }, |
@@ -184,9 +184,9 @@ discard block |
||
184 | 184 | 'attribute' => 'name', |
185 | 185 | 'model' => EnrollmentStatusType::class, |
186 | 186 | 'wrapper' => ['element' => 'span', |
187 | - 'class' => function ($crud, $column, $entry) { |
|
187 | + 'class' => function($crud, $column, $entry) { |
|
188 | 188 | return 'badge badge-pill badge-'.$entry->enrollmentStatus->styling(); |
189 | - }, ], ]]); |
|
189 | + },], ]]); |
|
190 | 190 | |
191 | 191 | if (config('invoicing.allow_scheduled_payments')) { |
192 | 192 | CRUD::addColumn(['name' => 'scheduledPayments', |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | if ($this->mode === 'global') { |
233 | 233 | CRUD::addFilter(['name' => 'status_id', |
234 | 234 | 'type' => 'select2_multiple', |
235 | - 'label' => __('Status'), ], fn () => EnrollmentStatusType::all()->pluck('name', 'id')->toArray(), function ($values) { |
|
235 | + 'label' => __('Status'), ], fn() => EnrollmentStatusType::all()->pluck('name', 'id')->toArray(), function($values) { |
|
236 | 236 | foreach (json_decode($values, null, 512, JSON_THROW_ON_ERROR) as $value) { |
237 | 237 | CRUD::addClause('orWhere', 'status_id', $value); |
238 | 238 | } |
@@ -240,17 +240,17 @@ discard block |
||
240 | 240 | |
241 | 241 | CRUD::addFilter(['name' => 'period_id', |
242 | 242 | 'type' => 'select2', |
243 | - 'label' => __('Period'), ], fn () => Period::all()->pluck('name', 'id')->toArray(), function ($value) { |
|
243 | + 'label' => __('Period'), ], fn() => Period::all()->pluck('name', 'id')->toArray(), function($value) { |
|
244 | 244 | CRUD::addClause('period', $value); |
245 | 245 | }); |
246 | 246 | |
247 | 247 | CRUD::addFilter(['name' => 'scholarship', |
248 | 248 | 'type' => 'select2', |
249 | - 'label' => __('Scholarship'), ], fn () => Scholarship::all()->pluck('name', 'id')->toArray(), function ($value) { |
|
249 | + 'label' => __('Scholarship'), ], fn() => Scholarship::all()->pluck('name', 'id')->toArray(), function($value) { |
|
250 | 250 | if ($value == 'all') { |
251 | 251 | CRUD::addClause('whereHas', 'scholarships'); |
252 | 252 | } else { |
253 | - CRUD::addClause('whereHas', 'scholarships', function ($q) use ($value) { |
|
253 | + CRUD::addClause('whereHas', 'scholarships', function($q) use ($value) { |
|
254 | 254 | $q->where('scholarships.id', $value); |
255 | 255 | }); |
256 | 256 | } |
@@ -271,8 +271,8 @@ discard block |
||
271 | 271 | // then load the page |
272 | 272 | $commentsIncludingInvoices = $enrollment->comments |
273 | 273 | ->concat($enrollment->invoices() |
274 | - ->map(fn($invoice) => $invoice->comments->map(function ($comment) use ($invoice) { |
|
275 | - $comment->prefix = '(' . __('Invoice') . " " . ($invoice->invoice_reference ?? $invoice->id) . ")"; |
|
274 | + ->map(fn($invoice) => $invoice->comments->map(function($comment) use ($invoice) { |
|
275 | + $comment->prefix = '('.__('Invoice')." ".($invoice->invoice_reference ?? $invoice->id).")"; |
|
276 | 276 | return $comment; |
277 | 277 | })) |
278 | 278 | ->flatten() |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | 'model' => Course::class, |
305 | 305 | 'attribute' => 'name', |
306 | 306 | |
307 | - 'options' => (fn ($query) => $query->orderBy('level_id', 'ASC')->where('period_id', $this->crud->getCurrentEntry()->course->period_id)->get()), |
|
307 | + 'options' => (fn($query) => $query->orderBy('level_id', 'ASC')->where('period_id', $this->crud->getCurrentEntry()->course->period_id)->get()), |
|
308 | 308 | ]); |
309 | 309 | |
310 | 310 | CRUD::addField(array_merge([ |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | CRUD::setModel(Invoice::class); |
30 | 30 | CRUD::setRoute(config('backpack.base.route_prefix').'/invoice'); |
31 | 31 | CRUD::setEntityNameStrings(__('invoice'), __('invoices')); |
32 | - if (! config('invoicing.price_categories_enabled')) { |
|
32 | + if (!config('invoicing.price_categories_enabled')) { |
|
33 | 33 | $this->crud->addButtonFromView('top', 'createInvoice', 'createInvoice', 'start'); |
34 | 34 | } |
35 | 35 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | 'label' => __('Date range'), |
105 | 105 | ], |
106 | 106 | false, |
107 | - function ($value) { // if the filter is active, apply these constraints |
|
107 | + function($value) { // if the filter is active, apply these constraints |
|
108 | 108 | $dates = json_decode($value, null, 512, JSON_THROW_ON_ERROR); |
109 | 109 | |
110 | 110 | if ($dates->from) { |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | { |
148 | 148 | $invoice = Invoice::findOrFail($id)->load('payments'); |
149 | 149 | |
150 | - if (! backpack_user()->can('enrollments.edit')) { |
|
150 | + if (!backpack_user()->can('enrollments.edit')) { |
|
151 | 151 | abort(403); |
152 | 152 | } |
153 | 153 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | 'invoice' => $invoice, |
156 | 156 | 'availablePaymentMethods' => Paymentmethod::all(), |
157 | 157 | 'editable' => true, |
158 | - 'enrollment' => $invoice->enrollments->first()?->product, |
|
158 | + 'enrollment' => $invoice->enrollments->first() ? ->product, |
|
159 | 159 | 'comments' => $invoice->comments, |
160 | 160 | 'afterSuccessUrl' => $invoice->enrollments->count() > 0 ? "/enrollment/{$invoice->enrollments->first()->product_id}/show" : '/invoice', // TODO fix this, an invoice can theoretically contain several enrollments |
161 | 161 | ]); |