Passed
Push — master ( 50ec6a...ab58f2 )
by Thomas
08:07
created
app/Providers/AuthServiceProvider.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -30,69 +30,69 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
app/Http/Controllers/ScheduledPaymentController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -172,7 +172,7 @@
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
app/Http/Controllers/TeacherCalendarController.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
         $events = Event::with('course')
26 26
             ->where('start', '>', Carbon::now()->subDays(30))->where('end', '<', Carbon::now()->addDays(30))->orderBy('id', 'desc') // TODO optimize this.
27 27
             ->get()
28
-            ->map(fn ($event) => [
28
+            ->map(fn($event) => [
29 29
                 'title' => $event->name ?? '',
30 30
                 'resourceId' => $event->teacher_id,
31 31
                 'start' => $event->start,
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
 
38 38
         $teachers = Teacher::all()->toArray();
39 39
 
40
-        $teachers = array_map(fn ($teacher) => [
40
+        $teachers = array_map(fn($teacher) => [
41 41
             'id' => $teacher['id'],
42 42
             'title' => $teacher['name'] ?? '',
43 43
         ], $teachers);
44 44
 
45 45
         array_push($teachers, ['id' => 'tbd', 'title' => 'Unassigned']);
46 46
 
47
-        $unassigned_events = Event::unassigned()->get()->map(fn ($event) => [
47
+        $unassigned_events = Event::unassigned()->get()->map(fn($event) => [
48 48
             'title' => $event->name ?? '',
49 49
             'resourceId' => 'tbd',
50 50
             'start' => $event->start,
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
             'borderColor' => $event->color,
55 55
         ]);
56 56
 
57
-        $leaves = Leave::orderBy('date', 'desc')->limit(10000)->get()->map(fn ($event) => [
57
+        $leaves = Leave::orderBy('date', 'desc')->limit(10000)->get()->map(fn($event) => [
58 58
             'title' => $event->leaveType->name ?? 'ABS', // todo fix
59 59
             'resourceId' => $event['teacher_id'],
60 60
             'start' => $event['date'],
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
             abort(403);
81 81
         }
82 82
 
83
-        $events = $teacher->events->map(fn ($event) => [
83
+        $events = $teacher->events->map(fn($event) => [
84 84
             'title' => $event['name'],
85 85
             'start' => $event['start'],
86 86
             'end' => $event['end'],
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
             'borderColor' => $event['color'],
89 89
         ]);
90 90
 
91
-        $leaves = $teacher->leaves->map(fn ($event) => [
92
-            'title' => $event->leaveType->name ?? 'vacances',  // todo fix
91
+        $leaves = $teacher->leaves->map(fn($event) => [
92
+            'title' => $event->leaveType->name ?? 'vacances', // todo fix
93 93
             'start' => $event['date'],
94 94
             'allDay' => true,
95 95
         ]);
Please login to merge, or discard this patch.
app/Http/Controllers/RoomController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
             ->where('end', '<', Carbon::now()->addDays(90))
26 26
             ->orderBy('id', 'desc')
27 27
             ->get()
28
-            ->map(fn ($event) => [
28
+            ->map(fn($event) => [
29 29
                 'title' => $event->name,
30 30
                 'resourceId' => $event->room_id,
31 31
                 'start' => $event->start,
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
         $rooms = Room::all()->toArray();
39 39
 
40
-        $rooms = array_map(fn ($room) => [
40
+        $rooms = array_map(fn($room) => [
41 41
             'id' => $room['id'],
42 42
             'title' => $room['name'],
43 43
         ], $rooms);
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         $unassigned_events = Event::with('course')
48 48
             ->whereNull('room_id')
49 49
             ->get()
50
-            ->map(fn ($event) => [
50
+            ->map(fn($event) => [
51 51
                 'title' => $event->name,
52 52
                 'resourceId' => 'tbd',
53 53
                 'start' => $event->start,
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     public function show(Room $room)
71 71
     {
72 72
         $events = $room->events->toArray();
73
-        $events = array_map(fn ($event) => [
73
+        $events = array_map(fn($event) => [
74 74
             'title' => $event['name'],
75 75
             'start' => $event['start'],
76 76
             'end' => $event['end'],
Please login to merge, or discard this patch.
app/Http/Controllers/Admin/UserCrudController.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
                 'label' => trans('backpack::permissionmanager.email'),
49 49
                 'type'  => 'email',
50 50
             ],
51
-            [ // n-n relationship (with pivot table)
51
+            [// n-n relationship (with pivot table)
52 52
                 'label'     => trans('backpack::permissionmanager.roles'),
53 53
                 'type'      => 'select_multiple',
54 54
                 'name'      => 'roles',
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
                 'label' => trans('backpack::permissionmanager.role'),
68 68
             ],
69 69
             config('permission.models.role')::all()->pluck(['name', 'id'])->toArray(),
70
-            function ($value) {
70
+            function($value) {
71 71
                 // if the filter is active
72
-                $this->crud->addClause('whereHas', 'roles', function ($query) use ($value) {
72
+                $this->crud->addClause('whereHas', 'roles', function($query) use ($value) {
73 73
                     $query->where('role_id', '=', $value);
74 74
                 });
75 75
             }
@@ -120,12 +120,12 @@  discard block
 block discarded – undo
120 120
     protected function addFields()
121 121
     {
122 122
         $this->crud->addFields([
123
-            [  // Select2
123
+            [// Select2
124 124
                 'label' => trans('firstname'),
125 125
                 'type' => 'text',
126 126
                 'name' => 'firstname',
127 127
             ],
128
-            [  // Select2
128
+            [// Select2
129 129
                 'label' => trans('lastname'),
130 130
                 'type' => 'text',
131 131
                 'name' => 'lastname',
Please login to merge, or discard this patch.
app/Http/Controllers/Admin/EvaluationTypeCrudController.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     {
35 35
         CRUD::addField(['name' => 'name', 'label' => 'Name', 'type' => 'text']);
36 36
 
37
-        CRUD::addField([    // Select2Multiple = n-n relationship (with pivot table)
37
+        CRUD::addField([// Select2Multiple = n-n relationship (with pivot table)
38 38
             'label'     => __('Grade Types'),
39 39
             'type'      => 'select2_multiple',
40 40
             'name'      => 'gradeTypes',
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
             'select_all' => true, // show Select All and Clear buttons?
48 48
         ]);
49 49
 
50
-        CRUD::addField([    // Select2Multiple = n-n relationship (with pivot table)
50
+        CRUD::addField([// Select2Multiple = n-n relationship (with pivot table)
51 51
             'label'     => __('Skills'),
52 52
             'type'      => 'select2_multiple',
53 53
             'name'      => 'skills',
Please login to merge, or discard this patch.
app/Console/Commands/genderizeStudents.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -196,15 +196,15 @@
 block discarded – undo
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,
Please login to merge, or discard this patch.
app/Models/EnrollmentStatusType.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
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',
Please login to merge, or discard this patch.
app/Models/Student.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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)
Please login to merge, or discard this patch.