Passed
Pull Request — master (#291)
by
unknown
09:42
created
app/Http/Controllers/HomeController.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 
45 45
     public function teacher(Request $request)
46 46
     {
47
-        if (! backpack_user()->isTeacher()) {
47
+        if (!backpack_user()->isTeacher()) {
48 48
             abort(403);
49 49
         }
50 50
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
     public function student()
71 71
     {
72
-        if (! backpack_user()->isStudent()) {
72
+        if (!backpack_user()->isStudent()) {
73 73
             abort(403);
74 74
         }
75 75
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         $currentPeriod = Period::get_default_period();
88 88
         $enrollmentsPeriod = Period::get_enrollments_period();
89 89
 
90
-        if (! backpack_user()->hasRole(['admin', 'secretary'])) {
90
+        if (!backpack_user()->hasRole(['admin', 'secretary'])) {
91 91
             abort(403);
92 92
         }
93 93
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
         // todo optimize this !!
97 97
         $events = Event::where('start', '>', Carbon::now()->subDays(15))->where('end', '<', Carbon::now()->addDays(15))->orderBy('id', 'desc')
98 98
             ->get()
99
-            ->map(fn ($event) => [
99
+            ->map(fn($event) => [
100 100
                 'title' => $event['name'],
101 101
                 'resourceId' => $event['teacher_id'],
102 102
                 'start' => $event['start'],
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 
109 109
         $teachers = Teacher::with('user')->get()->toArray();
110 110
 
111
-        $teachers = array_map(fn ($teacher) => [
111
+        $teachers = array_map(fn($teacher) => [
112 112
             'id' => $teacher['id'],
113 113
             'title' => $teacher['user']['firstname'],
114 114
         ], $teachers);
Please login to merge, or discard this patch.
app/Services/ApolearnService.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 
134 134
     public function updateCourse(Course $course): void
135 135
     {
136
-        if (! $course->lms_id) {
136
+        if (!$course->lms_id) {
137 137
             $this->createCourse($course);
138 138
         }
139 139
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
             Log::info('found these teachers IDs on LMS:'.implode(', ', $teachers->pluck('id')->toArray()));
163 163
 
164 164
             // if the course has no teacher, stop
165
-            if (! $course->teacher) {
165
+            if (!$course->teacher) {
166 166
                 Log::alert('The course has no teacher on local system, removing all teachers from remote');
167 167
                 foreach ($teachers as $teacher) {
168 168
                     $this->removeTeacher($course->lms_id, $teacher['id']);
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
                     }
178 178
                 }
179 179
 
180
-                if (! $course->teacher->user->lms_id || ! $teachers->contains('id', $course->teacher->user->lms_id)) {
180
+                if (!$course->teacher->user->lms_id || !$teachers->contains('id', $course->teacher->user->lms_id)) {
181 181
                     Log::info('the course teacher has changed, need to update it');
182 182
                     $this->addTeacher($course);
183 183
                 }
@@ -187,14 +187,14 @@  discard block
 block discarded – undo
187 187
 
188 188
     public function enrollStudent(Course $course, Student $student): void
189 189
     {
190
-        if (! $course->lms_id) {
190
+        if (!$course->lms_id) {
191 191
             abort(404, 'This course is not synced with external LMS');
192 192
         }
193 193
 
194 194
         $courseId = $course->lms_id;
195 195
 
196 196
         // if the student is not synced with the LMS, create them
197
-        if (! $student->user->lms_id) {
197
+        if (!$student->user->lms_id) {
198 198
             $this->createUser($student->user);
199 199
         }
200 200
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
         // only process if the course has a teacher
218 218
         if ($course->teacher_id) {
219 219
             // if the teacher doesn't exist on LMS, create them
220
-            if (! $course->teacher->user->lms_id) {
220
+            if (!$course->teacher->user->lms_id) {
221 221
                 Log::info('creating user now');
222 222
                 $this->createUser($course->teacher->user);
223 223
             }
Please login to merge, or discard this patch.
app/Models/Teacher.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -39,22 +39,22 @@  discard block
 block discarded – undo
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
 block discarded – undo
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');
Please login to merge, or discard this patch.
app/Models/ScheduledPayment.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 => '-',
Please login to merge, or discard this patch.
app/Models/Enrollment.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
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
@@ -349,8 +349,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,
Please login to merge, or discard this patch.
app/Http/Controllers/Admin/EventCrudController.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -116,13 +116,13 @@  discard block
 block discarded – undo
116 116
         ]);
117 117
 
118 118
         CRUD::addFilter(
119
-            [ // daterange filter
119
+            [// daterange filter
120 120
                 'type' => 'date_range',
121 121
                 'name' => 'from_to',
122 122
                 'label' => __('Date range'),
123 123
             ],
124 124
             false,
125
-            function ($value) { // if the filter is active, apply these constraints
125
+            function($value) { // if the filter is active, apply these constraints
126 126
                 $dates = json_decode($value, null, 512, JSON_THROW_ON_ERROR);
127 127
 
128 128
                 if ($dates->from) {
@@ -141,10 +141,10 @@  discard block
 block discarded – undo
141 141
                 'label' => __('Events with no course'),
142 142
             ],
143 143
             false,
144
-            function () { // if the filter is active, apply these constraints
144
+            function() { // if the filter is active, apply these constraints
145 145
                 $this->crud->query->where('course_id', null);
146 146
             },
147
-            function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit)
147
+            function() { // if the filter is NOT active (the GET parameter "checkbox" does not exit)
148 148
             }
149 149
         );
150 150
 
@@ -155,22 +155,22 @@  discard block
 block discarded – undo
155 155
                 'label' => __('Events with no teacher'),
156 156
             ],
157 157
             false,
158
-            function () { // if the filter is active, apply these constraints
158
+            function() { // if the filter is active, apply these constraints
159 159
                 CRUD::addClause('unassigned');
160 160
             }
161 161
         );
162 162
 
163 163
         CRUD::addFilter(
164
-            [ // select2 filter
164
+            [// select2 filter
165 165
                 'name' => 'teacher_id',
166 166
                 'type' => 'select2',
167 167
                 'label' => __('Teacher'),
168 168
             ],
169
-            fn () => Teacher::all()->pluck('name', 'id')->toArray(),
170
-            function ($value) {
169
+            fn() => Teacher::all()->pluck('name', 'id')->toArray(),
170
+            function($value) {
171 171
                 CRUD::addClause('where', 'teacher_id', $value);
172 172
             },
173
-            function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit)
173
+            function() { // if the filter is NOT active (the GET parameter "checkbox" does not exit)
174 174
             }
175 175
         );
176 176
     }
Please login to merge, or discard this patch.
app/Http/Controllers/Admin/TeacherCrudController.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
                 'attribute' => 'lastname',
47 47
                 'model' => User::class,
48 48
                 'orderable' => true,
49
-                'orderLogic' => fn ($query, $column, $columnDirection) => $query->leftJoin('users', 'users.id', '=', 'students.id')
49
+                'orderLogic' => fn($query, $column, $columnDirection) => $query->leftJoin('users', 'users.id', '=', 'students.id')
50 50
                     ->orderBy('users.lastname', $columnDirection)->select('students.*'),
51
-                'searchLogic' => function ($query, $column, $searchTerm) {
52
-                    $query->orWhereHas('user', function ($q) use ($searchTerm) {
51
+                'searchLogic' => function($query, $column, $searchTerm) {
52
+                    $query->orWhereHas('user', function($q) use ($searchTerm) {
53 53
                         $q->where('lastname', 'like', '%'.$searchTerm.'%');
54 54
                     });
55 55
                 },
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
                 'attribute' => 'firstname',
65 65
                 'model' => User::class,
66 66
                 'orderable' => true,
67
-                'orderLogic' => fn ($query, $column, $columnDirection) => $query->leftJoin('users', 'users.id', '=', 'teachers.id')
67
+                'orderLogic' => fn($query, $column, $columnDirection) => $query->leftJoin('users', 'users.id', '=', 'teachers.id')
68 68
                     ->orderBy('users.firstname', $columnDirection)->select('teachers.*'),
69
-                'searchLogic' => function ($query, $column, $searchTerm) {
70
-                    $query->orWhereHas('user', function ($q) use ($searchTerm) {
69
+                'searchLogic' => function($query, $column, $searchTerm) {
70
+                    $query->orWhereHas('user', function($q) use ($searchTerm) {
71 71
                         $q->where('firstname', 'like', '%'.$searchTerm.'%');
72 72
                     });
73 73
                 },
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
                 'attribute' => 'email',
82 82
                 'model' => User::class,
83 83
                 'orderable' => true,
84
-                'orderLogic' => fn ($query, $column, $columnDirection) => $query->leftJoin('users', 'users.id', '=', 'teachers.id')
84
+                'orderLogic' => fn($query, $column, $columnDirection) => $query->leftJoin('users', 'users.id', '=', 'teachers.id')
85 85
                     ->orderBy('users.email', $columnDirection)->select('teachers.*'),
86
-                'searchLogic' => function ($query, $column, $searchTerm) {
87
-                    $query->orWhereHas('user', function ($q) use ($searchTerm) {
86
+                'searchLogic' => function($query, $column, $searchTerm) {
87
+                    $query->orWhereHas('user', function($q) use ($searchTerm) {
88 88
                         $q->where('email', 'like', '%'.$searchTerm.'%');
89 89
                     });
90 90
                 },
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
         $username_parts = array_filter(explode(' ', strtolower($fullName)));
182 182
         $username_parts = array_slice($username_parts, -2);
183 183
 
184
-        $part1 = (! empty($username_parts[0])) ? substr($username_parts[0], 0, 3) : '';
185
-        $part2 = (! empty($username_parts[1])) ? substr($username_parts[1], 0, 8) : '';
184
+        $part1 = (!empty($username_parts[0])) ? substr($username_parts[0], 0, 3) : '';
185
+        $part2 = (!empty($username_parts[1])) ? substr($username_parts[1], 0, 8) : '';
186 186
         $part3 = random_int(999, 9999);
187 187
 
188 188
         //str_shuffle to randomly shuffle all characters
Please login to merge, or discard this patch.
app/Http/Controllers/Auth/RegisterController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
         $username_parts = array_filter(explode(' ', strtolower($fullName)));
32 32
         $username_parts = array_slice($username_parts, -2);
33 33
 
34
-        $part1 = (! empty($username_parts[0])) ? substr($username_parts[0], 0, 3) : '';
35
-        $part2 = (! empty($username_parts[1])) ? substr($username_parts[1], 0, 8) : '';
34
+        $part1 = (!empty($username_parts[0])) ? substr($username_parts[0], 0, 3) : '';
35
+        $part2 = (!empty($username_parts[1])) ? substr($username_parts[1], 0, 8) : '';
36 36
         $part3 = random_int(999, 9999);
37 37
 
38 38
         //str_shuffle to randomly shuffle all characters
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
     {
125 125
 
126 126
         // if registration is closed, deny access
127
-        if (! config('backpack.base.registration_open')) {
127
+        if (!config('backpack.base.registration_open')) {
128 128
             abort(403, trans('backpack::base.registration_closed'));
129 129
         }
130 130
 
Please login to merge, or discard this patch.