Passed
Pull Request — master (#273)
by
unknown
07:48
created
app/Http/Controllers/Admin/StudentCrudController.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
                 'attribute' => 'lastname', // foreign key attribute that is shown to user
89 89
                 'model'     => 'App\Models\User', // foreign key model
90 90
                 'orderable' => true,
91
-                'orderLogic' => function ($query, $column, $columnDirection) {
91
+                'orderLogic' => function($query, $column, $columnDirection) {
92 92
                     return $query->leftJoin('users', 'users.id', '=', 'students.id')
93 93
                         ->orderBy('users.lastname', $columnDirection)->select('students.*');
94 94
                 },
95
-                'searchLogic' => function ($query, $column, $searchTerm) {
96
-                    $query->orWhereHas('user', function ($q) use ($searchTerm) {
95
+                'searchLogic' => function($query, $column, $searchTerm) {
96
+                    $query->orWhereHas('user', function($q) use ($searchTerm) {
97 97
                         $q->where('lastname', 'like', '%'.$searchTerm.'%');
98 98
                     });
99 99
                 },
@@ -108,12 +108,12 @@  discard block
 block discarded – undo
108 108
                 'attribute' => 'firstname', // foreign key attribute that is shown to user
109 109
                 'model'     => 'App\Models\User', // foreign key model
110 110
                 'orderable' => true,
111
-                'orderLogic' => function ($query, $column, $columnDirection) {
111
+                'orderLogic' => function($query, $column, $columnDirection) {
112 112
                     return $query->leftJoin('users', 'users.id', '=', 'students.id')
113 113
                         ->orderBy('users.firstname', $columnDirection)->select('students.*');
114 114
                 },
115
-                'searchLogic' => function ($query, $column, $searchTerm) {
116
-                    $query->orWhereHas('user', function ($q) use ($searchTerm) {
115
+                'searchLogic' => function($query, $column, $searchTerm) {
116
+                    $query->orWhereHas('user', function($q) use ($searchTerm) {
117 117
                         $q->where('firstname', 'like', '%'.$searchTerm.'%');
118 118
                     });
119 119
                 },
@@ -127,12 +127,12 @@  discard block
 block discarded – undo
127 127
                 'attribute' => 'email', // foreign key attribute that is shown to user
128 128
                 'model'     => 'App\Models\User', // foreign key model
129 129
                 'orderable' => true,
130
-                'orderLogic' => function ($query, $column, $columnDirection) {
130
+                'orderLogic' => function($query, $column, $columnDirection) {
131 131
                     return $query->leftJoin('users', 'users.id', '=', 'students.id')
132 132
                         ->orderBy('users.email', $columnDirection)->select('students.*');
133 133
                 },
134
-                'searchLogic' => function ($query, $column, $searchTerm) {
135
-                    $query->orWhereHas('user', function ($q) use ($searchTerm) {
134
+                'searchLogic' => function($query, $column, $searchTerm) {
135
+                    $query->orWhereHas('user', function($q) use ($searchTerm) {
136 136
                         $q->where('email', 'like', '%'.$searchTerm.'%');
137 137
                     });
138 138
                 },
@@ -160,32 +160,32 @@  discard block
 block discarded – undo
160 160
 
161 161
         ]);
162 162
 
163
-        CRUD::addFilter([ // select2 filter
163
+        CRUD::addFilter([// select2 filter
164 164
             'name' => 'enrolled',
165 165
             'type' => 'select2',
166 166
             'label'=> __('Is Enrolled in'),
167
-        ], function () {
167
+        ], function() {
168 168
             return Period::all()->pluck('name', 'id')->toArray();
169
-        }, function ($value) { // if the filter is active
170
-            $this->crud->query = $this->crud->query->whereHas('enrollments', function ($query) use ($value) {
171
-                return $query->whereHas('course', function ($q) use ($value) {
169
+        }, function($value) { // if the filter is active
170
+            $this->crud->query = $this->crud->query->whereHas('enrollments', function($query) use ($value) {
171
+                return $query->whereHas('course', function($q) use ($value) {
172 172
                     $q->where('period_id', $value);
173 173
                 });
174 174
             });
175 175
         },
176
-          function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit)
176
+          function() { // if the filter is NOT active (the GET parameter "checkbox" does not exit)
177 177
           });
178 178
 
179
-        CRUD::addFilter([ // select2_multiple filter
179
+        CRUD::addFilter([// select2_multiple filter
180 180
             'name' => 'notenrolled',
181 181
             'type' => 'select2_multiple',
182 182
             'label'=> __('Is Not Enrolled in'),
183
-        ], function () { // the options that show up in the select2
183
+        ], function() { // the options that show up in the select2
184 184
             return Period::all()->pluck('name', 'id')->toArray();
185
-        }, function ($values) { // if the filter is active
185
+        }, function($values) { // if the filter is active
186 186
             foreach (json_decode($values) as $value) {
187
-                $this->crud->query = $this->crud->query->whereDoesntHave('enrollments', function ($query) use ($value) {
188
-                    return $query->whereHas('course', function ($q) use ($value) {
187
+                $this->crud->query = $this->crud->query->whereDoesntHave('enrollments', function($query) use ($value) {
188
+                    return $query->whereHas('course', function($q) use ($value) {
189 189
                         $q->where('period_id', $value);
190 190
                     });
191 191
                 });
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
             'name'  => 'institution_id',
198 198
             'type'  => 'select2',
199 199
             'label' => __('Institution'),
200
-        ], function () {
200
+        ], function() {
201 201
             return Institution::all()->pluck('name', 'id')->toArray();
202
-        }, function ($value) { // if the filter is active
202
+        }, function($value) { // if the filter is active
203 203
             $this->crud->addClause('where', 'institution_id', $value);
204 204
         });
205 205
 
@@ -207,10 +207,10 @@  discard block
 block discarded – undo
207 207
             'name'  => 'status_type_id',
208 208
             'type'  => 'select2',
209 209
             'label' => __('Lead Status'),
210
-        ], function () {
210
+        ], function() {
211 211
             return LeadType::all()->pluck('name', 'id')->toArray();
212
-        }, function ($value) {
213
-            $this->crud->addClause('where','lead_type_id', $value);
212
+        }, function($value) {
213
+            $this->crud->addClause('where', 'lead_type_id', $value);
214 214
         });
215 215
     }
216 216
 
@@ -300,11 +300,11 @@  discard block
 block discarded – undo
300 300
         $username_parts = array_filter(explode(" ", strtolower($fullName)));
301 301
         $username_parts = array_slice($username_parts, -2);
302 302
 
303
-        $part1 = (!empty($username_parts[0]))?substr($username_parts[0], 0,3):"";
304
-        $part2 = (!empty($username_parts[1]))?substr($username_parts[1], 0,8):"";
303
+        $part1 = (!empty($username_parts[0])) ?substr($username_parts[0], 0, 3) : "";
304
+        $part2 = (!empty($username_parts[1])) ?substr($username_parts[1], 0, 8) : "";
305 305
         $part3 = rand(999, 9999);
306 306
 
307
-        $username = $part1. $part2. $part3; //str_shuffle to randomly shuffle all characters
307
+        $username = $part1.$part2.$part3; //str_shuffle to randomly shuffle all characters
308 308
 
309 309
         return $username;
310 310
     }
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
             $username = $request->email;
323 323
         }
324 324
         else {
325
-            $username = $this->generateUsername($request->firstname . ' ' . $request->lastname);
325
+            $username = $this->generateUsername($request->firstname.' '.$request->lastname);
326 326
         }
327 327
 
328 328
         // update the user info
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
     {
392 392
         $student = Student::findOrFail($student);
393 393
 
394
-        if (! backpack_user()->isTeacher() && ! backpack_user()->can('enrollments.view')) {
394
+        if (!backpack_user()->isTeacher() && !backpack_user()->can('enrollments.view')) {
395 395
             abort(403);
396 396
         }
397 397
 
Please login to merge, or discard this patch.
app/Models/Period.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     {
76 76
         parent::boot();
77 77
 
78
-        static::addGlobalScope('order', function (Builder $builder) {
78
+        static::addGlobalScope('order', function(Builder $builder) {
79 79
             $builder->orderBy('year_id')->orderBy('order')->orderBy('id');
80 80
         });
81 81
     }
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     {
89 89
         $configPeriod = Config::where('name', 'current_period');
90 90
 
91
-        if($configPeriod->exists()) {
91
+        if ($configPeriod->exists()) {
92 92
             
93 93
             $currentPeriod = $configPeriod->first();
94 94
 
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
     {
226 226
         $period = self::where('id', '<', $this->id)->orderBy('id', 'desc')->first();
227 227
 
228
-        if (! $period == null) {
228
+        if (!$period == null) {
229 229
             return $period;
230 230
         } else {
231 231
             return self::first();
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
     public function getCoursesWithPendingAttendanceAttribute()
303 303
     {
304 304
         // get all courses for period and preload relations
305
-        $courses = $this->courses()->where(function ($query) {
305
+        $courses = $this->courses()->where(function($query) {
306 306
             $query->where('exempt_attendance', '!=', true);
307 307
             $query->where('exempt_attendance', '!=', 1);
308 308
             $query->orWhereNull('exempt_attendance');
Please login to merge, or discard this patch.