@@ -21,7 +21,7 @@ |
||
21 | 21 | parent::boot(); |
22 | 22 | |
23 | 23 | // when an attendance record is added, we check if this is an absence |
24 | - static::saved(function (self $attendance) { |
|
24 | + static::saved(function(self $attendance) { |
|
25 | 25 | if (config('app.send_emails_for_absences') && $attendance->attendance_type_id == 4) { // todo move to configurable settings |
26 | 26 | // Log::info('Absence marked for student '.$attendance->student->name); |
27 | 27 | // will check the record again and send a notification if it hasn't changed |
@@ -36,22 +36,22 @@ discard block |
||
36 | 36 | /** attributes */ |
37 | 37 | public function getFirstnameAttribute() : ?string |
38 | 38 | { |
39 | - return $this?->user?->firstname; |
|
39 | + return $this ? ->user ? ->firstname; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | public function getLastnameAttribute() : ?string |
43 | 43 | { |
44 | - return $this?->user?->lastname; |
|
44 | + return $this ? ->user ? ->lastname; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | public function getEmailAttribute() : ?string |
48 | 48 | { |
49 | - return $this?->user?->email; |
|
49 | + return $this ? ->user ? ->email; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | public function getNameAttribute() : ?string |
53 | 53 | { |
54 | - return $this?->user?->firstname.' '.$this?->user?->lastname; |
|
54 | + return $this ? ->user ? ->firstname.' '.$this ? ->user ? ->lastname; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | public function period_courses(Period $period) |
@@ -175,14 +175,14 @@ discard block |
||
175 | 175 | $eventsWithMissingAttendance = []; |
176 | 176 | |
177 | 177 | $eventsWithExpectedAttendance = $this->events() |
178 | - ->where(function ($query) { |
|
178 | + ->where(function($query) { |
|
179 | 179 | $query->where('exempt_attendance', '!=', true); |
180 | 180 | $query->where('exempt_attendance', '!=', 1); |
181 | 181 | $query->orWhereNull('exempt_attendance'); |
182 | 182 | }) |
183 | 183 | ->where('course_id', '!=', null) |
184 | - ->whereHas('course', fn (Builder $query) => $query->where('period_id', $period->id) |
|
185 | - ->where(function ($query) { |
|
184 | + ->whereHas('course', fn(Builder $query) => $query->where('period_id', $period->id) |
|
185 | + ->where(function($query) { |
|
186 | 186 | $query->where('exempt_attendance', '!=', true); |
187 | 187 | $query->where('exempt_attendance', '!=', 1); |
188 | 188 | $query->orWhereNull('exempt_attendance'); |
@@ -26,6 +26,6 @@ |
||
26 | 26 | */ |
27 | 27 | public function store_student_comment(User $user, Student $student) |
28 | 28 | { |
29 | - return ($student->enrollments()->whereHas('course', fn ($q) => $q->where('teacher_id', $user->id))->count() > 0) || $user->can('comments.edit'); |
|
29 | + return ($student->enrollments()->whereHas('course', fn($q) => $q->where('teacher_id', $user->id))->count() > 0) || $user->can('comments.edit'); |
|
30 | 30 | } |
31 | 31 | } |
@@ -30,69 +30,69 @@ |
||
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', fn ($user, $enrollment) => ($user->isTeacher() && $user->id == $enrollment->course->teacher_id) || $user->can('evaluation.edit')); |
|
96 | + Gate::define('edit-result', fn($user, $enrollment) => ($user->isTeacher() && $user->id == $enrollment->course->teacher_id) || $user->can('evaluation.edit')); |
|
97 | 97 | } |
98 | 98 | } |
@@ -172,7 +172,7 @@ |
||
172 | 172 | 'price_b' => $enrollment->course->price_b, |
173 | 173 | 'price_c' => $enrollment->course->price_c, |
174 | 174 | ]), |
175 | - 'studentPriceCategory' => $enrollment->student?->price_category, |
|
175 | + 'studentPriceCategory' => $enrollment->student ? ->price_category, |
|
176 | 176 | ] |
177 | 177 | ); |
178 | 178 | } |
@@ -172,7 +172,7 @@ |
||
172 | 172 | 'price_b' => $enrollment->course->price_b, |
173 | 173 | 'price_c' => $enrollment->course->price_c, |
174 | 174 | ]), |
175 | - 'studentPriceCategory' => $enrollment->student?->price_category, |
|
175 | + 'studentPriceCategory' => $enrollment->student ? ->price_category, |
|
176 | 176 | ] |
177 | 177 | ); |
178 | 178 | } |
@@ -15,184 +15,184 @@ |
||
15 | 15 | // wordpress implementation, from https://github.com/WordPress/WordPress/blob/a2693fd8602e3263b5925b9d799ddd577202167d/wp-includes/formatting.php#L1528 |
16 | 16 | private function remove_accents( $string ) { |
17 | 17 | |
18 | - $chars = array( |
|
19 | - // Decompositions for Latin-1 Supplement |
|
20 | - 'ª' => 'a', 'º' => 'o', |
|
21 | - 'À' => 'A', 'Á' => 'A', |
|
22 | - 'Â' => 'A', 'Ã' => 'A', |
|
23 | - 'Ä' => 'A', 'Å' => 'A', |
|
24 | - 'Æ' => 'AE','Ç' => 'C', |
|
25 | - 'È' => 'E', 'É' => 'E', |
|
26 | - 'Ê' => 'E', 'Ë' => 'E', |
|
27 | - 'Ì' => 'I', 'Í' => 'I', |
|
28 | - 'Î' => 'I', 'Ï' => 'I', |
|
29 | - 'Ð' => 'D', 'Ñ' => 'N', |
|
30 | - 'Ò' => 'O', 'Ó' => 'O', |
|
31 | - 'Ô' => 'O', 'Õ' => 'O', |
|
32 | - 'Ö' => 'O', 'Ù' => 'U', |
|
33 | - 'Ú' => 'U', 'Û' => 'U', |
|
34 | - 'Ü' => 'U', 'Ý' => 'Y', |
|
35 | - 'Þ' => 'TH','ß' => 's', |
|
36 | - 'à' => 'a', 'á' => 'a', |
|
37 | - 'â' => 'a', 'ã' => 'a', |
|
38 | - 'ä' => 'a', 'å' => 'a', |
|
39 | - 'æ' => 'ae','ç' => 'c', |
|
40 | - 'è' => 'e', 'é' => 'e', |
|
41 | - 'ê' => 'e', 'ë' => 'e', |
|
42 | - 'ì' => 'i', 'í' => 'i', |
|
43 | - 'î' => 'i', 'ï' => 'i', |
|
44 | - 'ð' => 'd', 'ñ' => 'n', |
|
45 | - 'ò' => 'o', 'ó' => 'o', |
|
46 | - 'ô' => 'o', 'õ' => 'o', |
|
47 | - 'ö' => 'o', 'ø' => 'o', |
|
48 | - 'ù' => 'u', 'ú' => 'u', |
|
49 | - 'û' => 'u', 'ü' => 'u', |
|
50 | - 'ý' => 'y', 'þ' => 'th', |
|
51 | - 'ÿ' => 'y', 'Ø' => 'O', |
|
52 | - // Decompositions for Latin Extended-A |
|
53 | - 'Ā' => 'A', 'ā' => 'a', |
|
54 | - 'Ă' => 'A', 'ă' => 'a', |
|
55 | - 'Ą' => 'A', 'ą' => 'a', |
|
56 | - 'Ć' => 'C', 'ć' => 'c', |
|
57 | - 'Ĉ' => 'C', 'ĉ' => 'c', |
|
58 | - 'Ċ' => 'C', 'ċ' => 'c', |
|
59 | - 'Č' => 'C', 'č' => 'c', |
|
60 | - 'Ď' => 'D', 'ď' => 'd', |
|
61 | - 'Đ' => 'D', 'đ' => 'd', |
|
62 | - 'Ē' => 'E', 'ē' => 'e', |
|
63 | - 'Ĕ' => 'E', 'ĕ' => 'e', |
|
64 | - 'Ė' => 'E', 'ė' => 'e', |
|
65 | - 'Ę' => 'E', 'ę' => 'e', |
|
66 | - 'Ě' => 'E', 'ě' => 'e', |
|
67 | - 'Ĝ' => 'G', 'ĝ' => 'g', |
|
68 | - 'Ğ' => 'G', 'ğ' => 'g', |
|
69 | - 'Ġ' => 'G', 'ġ' => 'g', |
|
70 | - 'Ģ' => 'G', 'ģ' => 'g', |
|
71 | - 'Ĥ' => 'H', 'ĥ' => 'h', |
|
72 | - 'Ħ' => 'H', 'ħ' => 'h', |
|
73 | - 'Ĩ' => 'I', 'ĩ' => 'i', |
|
74 | - 'Ī' => 'I', 'ī' => 'i', |
|
75 | - 'Ĭ' => 'I', 'ĭ' => 'i', |
|
76 | - 'Į' => 'I', 'į' => 'i', |
|
77 | - 'İ' => 'I', 'ı' => 'i', |
|
78 | - 'IJ' => 'IJ','ij' => 'ij', |
|
79 | - 'Ĵ' => 'J', 'ĵ' => 'j', |
|
80 | - 'Ķ' => 'K', 'ķ' => 'k', |
|
81 | - 'ĸ' => 'k', 'Ĺ' => 'L', |
|
82 | - 'ĺ' => 'l', 'Ļ' => 'L', |
|
83 | - 'ļ' => 'l', 'Ľ' => 'L', |
|
84 | - 'ľ' => 'l', 'Ŀ' => 'L', |
|
85 | - 'ŀ' => 'l', 'Ł' => 'L', |
|
86 | - 'ł' => 'l', 'Ń' => 'N', |
|
87 | - 'ń' => 'n', 'Ņ' => 'N', |
|
88 | - 'ņ' => 'n', 'Ň' => 'N', |
|
89 | - 'ň' => 'n', 'ʼn' => 'n', |
|
90 | - 'Ŋ' => 'N', 'ŋ' => 'n', |
|
91 | - 'Ō' => 'O', 'ō' => 'o', |
|
92 | - 'Ŏ' => 'O', 'ŏ' => 'o', |
|
93 | - 'Ő' => 'O', 'ő' => 'o', |
|
94 | - 'Œ' => 'OE','œ' => 'oe', |
|
95 | - 'Ŕ' => 'R','ŕ' => 'r', |
|
96 | - 'Ŗ' => 'R','ŗ' => 'r', |
|
97 | - 'Ř' => 'R','ř' => 'r', |
|
98 | - 'Ś' => 'S','ś' => 's', |
|
99 | - 'Ŝ' => 'S','ŝ' => 's', |
|
100 | - 'Ş' => 'S','ş' => 's', |
|
101 | - 'Š' => 'S', 'š' => 's', |
|
102 | - 'Ţ' => 'T', 'ţ' => 't', |
|
103 | - 'Ť' => 'T', 'ť' => 't', |
|
104 | - 'Ŧ' => 'T', 'ŧ' => 't', |
|
105 | - 'Ũ' => 'U', 'ũ' => 'u', |
|
106 | - 'Ū' => 'U', 'ū' => 'u', |
|
107 | - 'Ŭ' => 'U', 'ŭ' => 'u', |
|
108 | - 'Ů' => 'U', 'ů' => 'u', |
|
109 | - 'Ű' => 'U', 'ű' => 'u', |
|
110 | - 'Ų' => 'U', 'ų' => 'u', |
|
111 | - 'Ŵ' => 'W', 'ŵ' => 'w', |
|
112 | - 'Ŷ' => 'Y', 'ŷ' => 'y', |
|
113 | - 'Ÿ' => 'Y', 'Ź' => 'Z', |
|
114 | - 'ź' => 'z', 'Ż' => 'Z', |
|
115 | - 'ż' => 'z', 'Ž' => 'Z', |
|
116 | - 'ž' => 'z', 'ſ' => 's', |
|
117 | - // Decompositions for Latin Extended-B |
|
118 | - 'Ș' => 'S', 'ș' => 's', |
|
119 | - 'Ț' => 'T', 'ț' => 't', |
|
120 | - // Euro Sign |
|
121 | - '€' => 'E', |
|
122 | - // GBP (Pound) Sign |
|
123 | - '£' => '', |
|
124 | - // Vowels with diacritic (Vietnamese) |
|
125 | - // unmarked |
|
126 | - 'Ơ' => 'O', 'ơ' => 'o', |
|
127 | - 'Ư' => 'U', 'ư' => 'u', |
|
128 | - // grave accent |
|
129 | - 'Ầ' => 'A', 'ầ' => 'a', |
|
130 | - 'Ằ' => 'A', 'ằ' => 'a', |
|
131 | - 'Ề' => 'E', 'ề' => 'e', |
|
132 | - 'Ồ' => 'O', 'ồ' => 'o', |
|
133 | - 'Ờ' => 'O', 'ờ' => 'o', |
|
134 | - 'Ừ' => 'U', 'ừ' => 'u', |
|
135 | - 'Ỳ' => 'Y', 'ỳ' => 'y', |
|
136 | - // hook |
|
137 | - 'Ả' => 'A', 'ả' => 'a', |
|
138 | - 'Ẩ' => 'A', 'ẩ' => 'a', |
|
139 | - 'Ẳ' => 'A', 'ẳ' => 'a', |
|
140 | - 'Ẻ' => 'E', 'ẻ' => 'e', |
|
141 | - 'Ể' => 'E', 'ể' => 'e', |
|
142 | - 'Ỉ' => 'I', 'ỉ' => 'i', |
|
143 | - 'Ỏ' => 'O', 'ỏ' => 'o', |
|
144 | - 'Ổ' => 'O', 'ổ' => 'o', |
|
145 | - 'Ở' => 'O', 'ở' => 'o', |
|
146 | - 'Ủ' => 'U', 'ủ' => 'u', |
|
147 | - 'Ử' => 'U', 'ử' => 'u', |
|
148 | - 'Ỷ' => 'Y', 'ỷ' => 'y', |
|
149 | - // tilde |
|
150 | - 'Ẫ' => 'A', 'ẫ' => 'a', |
|
151 | - 'Ẵ' => 'A', 'ẵ' => 'a', |
|
152 | - 'Ẽ' => 'E', 'ẽ' => 'e', |
|
153 | - 'Ễ' => 'E', 'ễ' => 'e', |
|
154 | - 'Ỗ' => 'O', 'ỗ' => 'o', |
|
155 | - 'Ỡ' => 'O', 'ỡ' => 'o', |
|
156 | - 'Ữ' => 'U', 'ữ' => 'u', |
|
157 | - 'Ỹ' => 'Y', 'ỹ' => 'y', |
|
158 | - // acute accent |
|
159 | - 'Ấ' => 'A', 'ấ' => 'a', |
|
160 | - 'Ắ' => 'A', 'ắ' => 'a', |
|
161 | - 'Ế' => 'E', 'ế' => 'e', |
|
162 | - 'Ố' => 'O', 'ố' => 'o', |
|
163 | - 'Ớ' => 'O', 'ớ' => 'o', |
|
164 | - 'Ứ' => 'U', 'ứ' => 'u', |
|
165 | - // dot below |
|
166 | - 'Ạ' => 'A', 'ạ' => 'a', |
|
167 | - 'Ậ' => 'A', 'ậ' => 'a', |
|
168 | - 'Ặ' => 'A', 'ặ' => 'a', |
|
169 | - 'Ẹ' => 'E', 'ẹ' => 'e', |
|
170 | - 'Ệ' => 'E', 'ệ' => 'e', |
|
171 | - 'Ị' => 'I', 'ị' => 'i', |
|
172 | - 'Ọ' => 'O', 'ọ' => 'o', |
|
173 | - 'Ộ' => 'O', 'ộ' => 'o', |
|
174 | - 'Ợ' => 'O', 'ợ' => 'o', |
|
175 | - 'Ụ' => 'U', 'ụ' => 'u', |
|
176 | - 'Ự' => 'U', 'ự' => 'u', |
|
177 | - 'Ỵ' => 'Y', 'ỵ' => 'y', |
|
178 | - // Vowels with diacritic (Chinese, Hanyu Pinyin) |
|
179 | - 'ɑ' => 'a', |
|
180 | - // macron |
|
181 | - 'Ǖ' => 'U', 'ǖ' => 'u', |
|
182 | - // acute accent |
|
183 | - 'Ǘ' => 'U', 'ǘ' => 'u', |
|
184 | - // caron |
|
185 | - 'Ǎ' => 'A', 'ǎ' => 'a', |
|
186 | - 'Ǐ' => 'I', 'ǐ' => 'i', |
|
187 | - 'Ǒ' => 'O', 'ǒ' => 'o', |
|
188 | - 'Ǔ' => 'U', 'ǔ' => 'u', |
|
189 | - 'Ǚ' => 'U', 'ǚ' => 'u', |
|
190 | - // grave accent |
|
191 | - 'Ǜ' => 'U', 'ǜ' => 'u', |
|
192 | - ); |
|
18 | + $chars = array( |
|
19 | + // Decompositions for Latin-1 Supplement |
|
20 | + 'ª' => 'a', 'º' => 'o', |
|
21 | + 'À' => 'A', 'Á' => 'A', |
|
22 | + 'Â' => 'A', 'Ã' => 'A', |
|
23 | + 'Ä' => 'A', 'Å' => 'A', |
|
24 | + 'Æ' => 'AE','Ç' => 'C', |
|
25 | + 'È' => 'E', 'É' => 'E', |
|
26 | + 'Ê' => 'E', 'Ë' => 'E', |
|
27 | + 'Ì' => 'I', 'Í' => 'I', |
|
28 | + 'Î' => 'I', 'Ï' => 'I', |
|
29 | + 'Ð' => 'D', 'Ñ' => 'N', |
|
30 | + 'Ò' => 'O', 'Ó' => 'O', |
|
31 | + 'Ô' => 'O', 'Õ' => 'O', |
|
32 | + 'Ö' => 'O', 'Ù' => 'U', |
|
33 | + 'Ú' => 'U', 'Û' => 'U', |
|
34 | + 'Ü' => 'U', 'Ý' => 'Y', |
|
35 | + 'Þ' => 'TH','ß' => 's', |
|
36 | + 'à' => 'a', 'á' => 'a', |
|
37 | + 'â' => 'a', 'ã' => 'a', |
|
38 | + 'ä' => 'a', 'å' => 'a', |
|
39 | + 'æ' => 'ae','ç' => 'c', |
|
40 | + 'è' => 'e', 'é' => 'e', |
|
41 | + 'ê' => 'e', 'ë' => 'e', |
|
42 | + 'ì' => 'i', 'í' => 'i', |
|
43 | + 'î' => 'i', 'ï' => 'i', |
|
44 | + 'ð' => 'd', 'ñ' => 'n', |
|
45 | + 'ò' => 'o', 'ó' => 'o', |
|
46 | + 'ô' => 'o', 'õ' => 'o', |
|
47 | + 'ö' => 'o', 'ø' => 'o', |
|
48 | + 'ù' => 'u', 'ú' => 'u', |
|
49 | + 'û' => 'u', 'ü' => 'u', |
|
50 | + 'ý' => 'y', 'þ' => 'th', |
|
51 | + 'ÿ' => 'y', 'Ø' => 'O', |
|
52 | + // Decompositions for Latin Extended-A |
|
53 | + 'Ā' => 'A', 'ā' => 'a', |
|
54 | + 'Ă' => 'A', 'ă' => 'a', |
|
55 | + 'Ą' => 'A', 'ą' => 'a', |
|
56 | + 'Ć' => 'C', 'ć' => 'c', |
|
57 | + 'Ĉ' => 'C', 'ĉ' => 'c', |
|
58 | + 'Ċ' => 'C', 'ċ' => 'c', |
|
59 | + 'Č' => 'C', 'č' => 'c', |
|
60 | + 'Ď' => 'D', 'ď' => 'd', |
|
61 | + 'Đ' => 'D', 'đ' => 'd', |
|
62 | + 'Ē' => 'E', 'ē' => 'e', |
|
63 | + 'Ĕ' => 'E', 'ĕ' => 'e', |
|
64 | + 'Ė' => 'E', 'ė' => 'e', |
|
65 | + 'Ę' => 'E', 'ę' => 'e', |
|
66 | + 'Ě' => 'E', 'ě' => 'e', |
|
67 | + 'Ĝ' => 'G', 'ĝ' => 'g', |
|
68 | + 'Ğ' => 'G', 'ğ' => 'g', |
|
69 | + 'Ġ' => 'G', 'ġ' => 'g', |
|
70 | + 'Ģ' => 'G', 'ģ' => 'g', |
|
71 | + 'Ĥ' => 'H', 'ĥ' => 'h', |
|
72 | + 'Ħ' => 'H', 'ħ' => 'h', |
|
73 | + 'Ĩ' => 'I', 'ĩ' => 'i', |
|
74 | + 'Ī' => 'I', 'ī' => 'i', |
|
75 | + 'Ĭ' => 'I', 'ĭ' => 'i', |
|
76 | + 'Į' => 'I', 'į' => 'i', |
|
77 | + 'İ' => 'I', 'ı' => 'i', |
|
78 | + 'IJ' => 'IJ','ij' => 'ij', |
|
79 | + 'Ĵ' => 'J', 'ĵ' => 'j', |
|
80 | + 'Ķ' => 'K', 'ķ' => 'k', |
|
81 | + 'ĸ' => 'k', 'Ĺ' => 'L', |
|
82 | + 'ĺ' => 'l', 'Ļ' => 'L', |
|
83 | + 'ļ' => 'l', 'Ľ' => 'L', |
|
84 | + 'ľ' => 'l', 'Ŀ' => 'L', |
|
85 | + 'ŀ' => 'l', 'Ł' => 'L', |
|
86 | + 'ł' => 'l', 'Ń' => 'N', |
|
87 | + 'ń' => 'n', 'Ņ' => 'N', |
|
88 | + 'ņ' => 'n', 'Ň' => 'N', |
|
89 | + 'ň' => 'n', 'ʼn' => 'n', |
|
90 | + 'Ŋ' => 'N', 'ŋ' => 'n', |
|
91 | + 'Ō' => 'O', 'ō' => 'o', |
|
92 | + 'Ŏ' => 'O', 'ŏ' => 'o', |
|
93 | + 'Ő' => 'O', 'ő' => 'o', |
|
94 | + 'Œ' => 'OE','œ' => 'oe', |
|
95 | + 'Ŕ' => 'R','ŕ' => 'r', |
|
96 | + 'Ŗ' => 'R','ŗ' => 'r', |
|
97 | + 'Ř' => 'R','ř' => 'r', |
|
98 | + 'Ś' => 'S','ś' => 's', |
|
99 | + 'Ŝ' => 'S','ŝ' => 's', |
|
100 | + 'Ş' => 'S','ş' => 's', |
|
101 | + 'Š' => 'S', 'š' => 's', |
|
102 | + 'Ţ' => 'T', 'ţ' => 't', |
|
103 | + 'Ť' => 'T', 'ť' => 't', |
|
104 | + 'Ŧ' => 'T', 'ŧ' => 't', |
|
105 | + 'Ũ' => 'U', 'ũ' => 'u', |
|
106 | + 'Ū' => 'U', 'ū' => 'u', |
|
107 | + 'Ŭ' => 'U', 'ŭ' => 'u', |
|
108 | + 'Ů' => 'U', 'ů' => 'u', |
|
109 | + 'Ű' => 'U', 'ű' => 'u', |
|
110 | + 'Ų' => 'U', 'ų' => 'u', |
|
111 | + 'Ŵ' => 'W', 'ŵ' => 'w', |
|
112 | + 'Ŷ' => 'Y', 'ŷ' => 'y', |
|
113 | + 'Ÿ' => 'Y', 'Ź' => 'Z', |
|
114 | + 'ź' => 'z', 'Ż' => 'Z', |
|
115 | + 'ż' => 'z', 'Ž' => 'Z', |
|
116 | + 'ž' => 'z', 'ſ' => 's', |
|
117 | + // Decompositions for Latin Extended-B |
|
118 | + 'Ș' => 'S', 'ș' => 's', |
|
119 | + 'Ț' => 'T', 'ț' => 't', |
|
120 | + // Euro Sign |
|
121 | + '€' => 'E', |
|
122 | + // GBP (Pound) Sign |
|
123 | + '£' => '', |
|
124 | + // Vowels with diacritic (Vietnamese) |
|
125 | + // unmarked |
|
126 | + 'Ơ' => 'O', 'ơ' => 'o', |
|
127 | + 'Ư' => 'U', 'ư' => 'u', |
|
128 | + // grave accent |
|
129 | + 'Ầ' => 'A', 'ầ' => 'a', |
|
130 | + 'Ằ' => 'A', 'ằ' => 'a', |
|
131 | + 'Ề' => 'E', 'ề' => 'e', |
|
132 | + 'Ồ' => 'O', 'ồ' => 'o', |
|
133 | + 'Ờ' => 'O', 'ờ' => 'o', |
|
134 | + 'Ừ' => 'U', 'ừ' => 'u', |
|
135 | + 'Ỳ' => 'Y', 'ỳ' => 'y', |
|
136 | + // hook |
|
137 | + 'Ả' => 'A', 'ả' => 'a', |
|
138 | + 'Ẩ' => 'A', 'ẩ' => 'a', |
|
139 | + 'Ẳ' => 'A', 'ẳ' => 'a', |
|
140 | + 'Ẻ' => 'E', 'ẻ' => 'e', |
|
141 | + 'Ể' => 'E', 'ể' => 'e', |
|
142 | + 'Ỉ' => 'I', 'ỉ' => 'i', |
|
143 | + 'Ỏ' => 'O', 'ỏ' => 'o', |
|
144 | + 'Ổ' => 'O', 'ổ' => 'o', |
|
145 | + 'Ở' => 'O', 'ở' => 'o', |
|
146 | + 'Ủ' => 'U', 'ủ' => 'u', |
|
147 | + 'Ử' => 'U', 'ử' => 'u', |
|
148 | + 'Ỷ' => 'Y', 'ỷ' => 'y', |
|
149 | + // tilde |
|
150 | + 'Ẫ' => 'A', 'ẫ' => 'a', |
|
151 | + 'Ẵ' => 'A', 'ẵ' => 'a', |
|
152 | + 'Ẽ' => 'E', 'ẽ' => 'e', |
|
153 | + 'Ễ' => 'E', 'ễ' => 'e', |
|
154 | + 'Ỗ' => 'O', 'ỗ' => 'o', |
|
155 | + 'Ỡ' => 'O', 'ỡ' => 'o', |
|
156 | + 'Ữ' => 'U', 'ữ' => 'u', |
|
157 | + 'Ỹ' => 'Y', 'ỹ' => 'y', |
|
158 | + // acute accent |
|
159 | + 'Ấ' => 'A', 'ấ' => 'a', |
|
160 | + 'Ắ' => 'A', 'ắ' => 'a', |
|
161 | + 'Ế' => 'E', 'ế' => 'e', |
|
162 | + 'Ố' => 'O', 'ố' => 'o', |
|
163 | + 'Ớ' => 'O', 'ớ' => 'o', |
|
164 | + 'Ứ' => 'U', 'ứ' => 'u', |
|
165 | + // dot below |
|
166 | + 'Ạ' => 'A', 'ạ' => 'a', |
|
167 | + 'Ậ' => 'A', 'ậ' => 'a', |
|
168 | + 'Ặ' => 'A', 'ặ' => 'a', |
|
169 | + 'Ẹ' => 'E', 'ẹ' => 'e', |
|
170 | + 'Ệ' => 'E', 'ệ' => 'e', |
|
171 | + 'Ị' => 'I', 'ị' => 'i', |
|
172 | + 'Ọ' => 'O', 'ọ' => 'o', |
|
173 | + 'Ộ' => 'O', 'ộ' => 'o', |
|
174 | + 'Ợ' => 'O', 'ợ' => 'o', |
|
175 | + 'Ụ' => 'U', 'ụ' => 'u', |
|
176 | + 'Ự' => 'U', 'ự' => 'u', |
|
177 | + 'Ỵ' => 'Y', 'ỵ' => 'y', |
|
178 | + // Vowels with diacritic (Chinese, Hanyu Pinyin) |
|
179 | + 'ɑ' => 'a', |
|
180 | + // macron |
|
181 | + 'Ǖ' => 'U', 'ǖ' => 'u', |
|
182 | + // acute accent |
|
183 | + 'Ǘ' => 'U', 'ǘ' => 'u', |
|
184 | + // caron |
|
185 | + 'Ǎ' => 'A', 'ǎ' => 'a', |
|
186 | + 'Ǐ' => 'I', 'ǐ' => 'i', |
|
187 | + 'Ǒ' => 'O', 'ǒ' => 'o', |
|
188 | + 'Ǔ' => 'U', 'ǔ' => 'u', |
|
189 | + 'Ǚ' => 'U', 'ǚ' => 'u', |
|
190 | + // grave accent |
|
191 | + 'Ǜ' => 'U', 'ǜ' => 'u', |
|
192 | + ); |
|
193 | 193 | |
194 | - return strtr($string, $chars); |
|
195 | - } |
|
194 | + return strtr($string, $chars); |
|
195 | + } |
|
196 | 196 | |
197 | 197 | |
198 | 198 | public function handle() |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | protected $description = 'Guess gender for existing students, based on their firstname'; |
14 | 14 | |
15 | 15 | // wordpress implementation, from https://github.com/WordPress/WordPress/blob/a2693fd8602e3263b5925b9d799ddd577202167d/wp-includes/formatting.php#L1528 |
16 | - private function remove_accents( $string ) { |
|
16 | + private function remove_accents($string) { |
|
17 | 17 | |
18 | 18 | $chars = array( |
19 | 19 | // Decompositions for Latin-1 Supplement |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | 'À' => 'A', 'Á' => 'A', |
22 | 22 | 'Â' => 'A', 'Ã' => 'A', |
23 | 23 | 'Ä' => 'A', 'Å' => 'A', |
24 | - 'Æ' => 'AE','Ç' => 'C', |
|
24 | + 'Æ' => 'AE', 'Ç' => 'C', |
|
25 | 25 | 'È' => 'E', 'É' => 'E', |
26 | 26 | 'Ê' => 'E', 'Ë' => 'E', |
27 | 27 | 'Ì' => 'I', 'Í' => 'I', |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | 'Ö' => 'O', 'Ù' => 'U', |
33 | 33 | 'Ú' => 'U', 'Û' => 'U', |
34 | 34 | 'Ü' => 'U', 'Ý' => 'Y', |
35 | - 'Þ' => 'TH','ß' => 's', |
|
35 | + 'Þ' => 'TH', 'ß' => 's', |
|
36 | 36 | 'à' => 'a', 'á' => 'a', |
37 | 37 | 'â' => 'a', 'ã' => 'a', |
38 | 38 | 'ä' => 'a', 'å' => 'a', |
39 | - 'æ' => 'ae','ç' => 'c', |
|
39 | + 'æ' => 'ae', 'ç' => 'c', |
|
40 | 40 | 'è' => 'e', 'é' => 'e', |
41 | 41 | 'ê' => 'e', 'ë' => 'e', |
42 | 42 | 'ì' => 'i', 'í' => 'i', |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | 'Ĭ' => 'I', 'ĭ' => 'i', |
76 | 76 | 'Į' => 'I', 'į' => 'i', |
77 | 77 | 'İ' => 'I', 'ı' => 'i', |
78 | - 'IJ' => 'IJ','ij' => 'ij', |
|
78 | + 'IJ' => 'IJ', 'ij' => 'ij', |
|
79 | 79 | 'Ĵ' => 'J', 'ĵ' => 'j', |
80 | 80 | 'Ķ' => 'K', 'ķ' => 'k', |
81 | 81 | 'ĸ' => 'k', 'Ĺ' => 'L', |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | 'Ō' => 'O', 'ō' => 'o', |
92 | 92 | 'Ŏ' => 'O', 'ŏ' => 'o', |
93 | 93 | 'Ő' => 'O', 'ő' => 'o', |
94 | - 'Œ' => 'OE','œ' => 'oe', |
|
95 | - 'Ŕ' => 'R','ŕ' => 'r', |
|
96 | - 'Ŗ' => 'R','ŗ' => 'r', |
|
97 | - 'Ř' => 'R','ř' => 'r', |
|
98 | - 'Ś' => 'S','ś' => 's', |
|
99 | - 'Ŝ' => 'S','ŝ' => 's', |
|
100 | - 'Ş' => 'S','ş' => 's', |
|
94 | + 'Œ' => 'OE', 'œ' => 'oe', |
|
95 | + 'Ŕ' => 'R', 'ŕ' => 'r', |
|
96 | + 'Ŗ' => 'R', 'ŗ' => 'r', |
|
97 | + 'Ř' => 'R', 'ř' => 'r', |
|
98 | + 'Ś' => 'S', 'ś' => 's', |
|
99 | + 'Ŝ' => 'S', 'ŝ' => 's', |
|
100 | + 'Ş' => 'S', 'ş' => 's', |
|
101 | 101 | 'Š' => 'S', 'š' => 's', |
102 | 102 | 'Ţ' => 'T', 'ţ' => 't', |
103 | 103 | 'Ť' => 'T', 'ť' => 't', |
@@ -197,10 +197,10 @@ discard block |
||
197 | 197 | |
198 | 198 | public function handle() |
199 | 199 | { |
200 | - Student::whereNull('gender_id')->chunkById(10, function ($students) { |
|
200 | + Student::whereNull('gender_id')->chunkById(10, function($students) { |
|
201 | 201 | $query = $students->map(fn($student) => ['id' => $student->id, 'name' => $this->remove_accents(strtok($student->firstname, " "))]); |
202 | 202 | |
203 | - $response = Http::get('https://api.genderize.io/?name[]=' . $query->pluck('name')->implode('&name[]=')); |
|
203 | + $response = Http::get('https://api.genderize.io/?name[]='.$query->pluck('name')->implode('&name[]=')); |
|
204 | 204 | foreach ($students as $student) { |
205 | 205 | $firstname = $query->firstWhere('id', $student->id)['name']; |
206 | 206 |
@@ -26,7 +26,7 @@ |
||
26 | 26 | |
27 | 27 | public function studentCount($gender = null) |
28 | 28 | { |
29 | - if (in_array($gender, [1,2])) { |
|
29 | + if (in_array($gender, [1, 2])) { |
|
30 | 30 | return DB::table('enrollments') |
31 | 31 | ->join('courses', 'enrollments.course_id', 'courses.id') |
32 | 32 | ->join('periods', 'courses.period_id', 'periods.id') |
@@ -63,7 +63,7 @@ |
||
63 | 63 | $year_data = []; |
64 | 64 | $years = []; // New array |
65 | 65 | |
66 | - if (! isset($request->period)) { |
|
66 | + if (!isset($request->period)) { |
|
67 | 67 | $startperiod = Period::find(Config::where('name', 'first_external_period')->first()->value ?? Period::first()->id); |
68 | 68 | } else { |
69 | 69 | $startperiod = Period::find($request->period); |