@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | 'attribute' => 'lastname', |
119 | 119 | 'label' => __('Last Name'), |
120 | 120 | 'type' => 'relationship', |
121 | - 'searchLogic' => function ($query, $column, $searchTerm) { |
|
122 | - $query->orWhereHas('student', function ($q) use ($searchTerm) { |
|
123 | - $q->whereHas('user', function ($q) use ($searchTerm) { |
|
121 | + 'searchLogic' => function($query, $column, $searchTerm) { |
|
122 | + $query->orWhereHas('student', function($q) use ($searchTerm) { |
|
123 | + $q->whereHas('user', function($q) use ($searchTerm) { |
|
124 | 124 | $q->where('lastname', 'like', '%'.$searchTerm.'%'); |
125 | 125 | }); |
126 | 126 | }); |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | 'attribute' => 'firstname', |
134 | 134 | 'label' => __('First Name'), |
135 | 135 | 'type' => 'relationship', |
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('firstname', 'like', '%'.$searchTerm.'%'); |
140 | 140 | }); |
141 | 141 | }); |
@@ -227,8 +227,8 @@ discard block |
||
227 | 227 | 'name' => 'status_id', |
228 | 228 | 'type' => 'select2_multiple', |
229 | 229 | 'label'=> __('Status'), |
230 | - ], fn () => EnrollmentStatusType::all()->pluck('name', 'id')->toArray(), |
|
231 | - function ($values) { |
|
230 | + ], fn() => EnrollmentStatusType::all()->pluck('name', 'id')->toArray(), |
|
231 | + function($values) { |
|
232 | 232 | // if the filter is active |
233 | 233 | foreach (json_decode($values, null, 512, JSON_THROW_ON_ERROR) as $value) { |
234 | 234 | CRUD::addClause('orWhere', 'status_id', $value); |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | 'name' => 'period_id', |
240 | 240 | 'type' => 'select2', |
241 | 241 | 'label'=> __('Period'), |
242 | - ], fn () => Period::all()->pluck('name', 'id')->toArray(), function ($value) { |
|
242 | + ], fn() => Period::all()->pluck('name', 'id')->toArray(), function($value) { |
|
243 | 243 | // if the filter is active |
244 | 244 | CRUD::addClause('period', $value); |
245 | 245 | }); |
@@ -250,12 +250,12 @@ discard block |
||
250 | 250 | 'type' => 'select2', |
251 | 251 | 'label'=> __('Scholarship'), |
252 | 252 | ], |
253 | - fn () => Scholarship::all()->pluck('name', 'id')->toArray(), |
|
254 | - function ($value) { // if the filter is active |
|
253 | + fn() => Scholarship::all()->pluck('name', 'id')->toArray(), |
|
254 | + function($value) { // if the filter is active |
|
255 | 255 | if ($value == 'all') { |
256 | 256 | CRUD::addClause('whereHas', 'scholarships'); |
257 | 257 | } else { |
258 | - CRUD::addClause('whereHas', 'scholarships', function ($q) use ($value) { |
|
258 | + CRUD::addClause('whereHas', 'scholarships', function($q) use ($value) { |
|
259 | 259 | $q->where('scholarships.id', $value); |
260 | 260 | }); |
261 | 261 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | ->get(); |
276 | 276 | |
277 | 277 | // get related comments |
278 | - $comments = $enrollment->invoices->map(fn (Invoice $invoice) => $invoice->comments)->flatten()->concat($enrollment->comments); |
|
278 | + $comments = $enrollment->invoices->map(fn(Invoice $invoice) => $invoice->comments)->flatten()->concat($enrollment->comments); |
|
279 | 279 | |
280 | 280 | $scholarships = Scholarship::all(); |
281 | 281 | |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | 'model' => \App\Models\Course::class, // foreign key model |
307 | 307 | 'attribute' => 'name', // foreign key attribute that is shown to user |
308 | 308 | |
309 | - 'options' => (fn ($query) => $query->orderBy('level_id', 'ASC')->where('period_id', $this->crud->getCurrentEntry()->course->period_id)->get()), |
|
309 | + 'options' => (fn($query) => $query->orderBy('level_id', 'ASC')->where('period_id', $this->crud->getCurrentEntry()->course->period_id)->get()), |
|
310 | 310 | ]); |
311 | 311 | |
312 | 312 | CRUD::addField(array_merge([ |
@@ -23,7 +23,7 @@ |
||
23 | 23 | |
24 | 24 | if (config('app.send_emails_for_results')) { |
25 | 25 | // when a result is added, send a notification |
26 | - static::saved(function (self $result) { |
|
26 | + static::saved(function(self $result) { |
|
27 | 27 | Mail::to($result->enrollment->student->user->email)->locale($result->enrollment->student->user->locale)->queue(new ResultNotification($result->enrollment->course, $result->enrollment->student->user)); |
28 | 28 | }); |
29 | 29 | } |
@@ -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 |
@@ -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 |
@@ -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 | } |