@@ -88,12 +88,12 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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,11 +207,11 @@ discard block  | 
                                                    ||
| 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) { | 
                                                        |
| 212 | +        }, function($value) { | 
                                                        |
| 213 | 213 | //dd($value);  | 
                                                        
| 214 | -            $this->crud->addClause('where','lead_type_id', $value); | 
                                                        |
| 214 | +            $this->crud->addClause('where', 'lead_type_id', $value); | 
                                                        |
| 215 | 215 | });  | 
                                                        
| 216 | 216 | }  | 
                                                        
| 217 | 217 | |
@@ -301,11 +301,11 @@ discard block  | 
                                                    ||
| 301 | 301 |          $username_parts = array_filter(explode(" ", strtolower($fullName))); | 
                                                        
| 302 | 302 | $username_parts = array_slice($username_parts, -2);  | 
                                                        
| 303 | 303 | |
| 304 | - $part1 = (!empty($username_parts[0]))?substr($username_parts[0], 0,3):"";  | 
                                                        |
| 305 | - $part2 = (!empty($username_parts[1]))?substr($username_parts[1], 0,8):"";  | 
                                                        |
| 304 | + $part1 = (!empty($username_parts[0])) ?substr($username_parts[0], 0, 3) : "";  | 
                                                        |
| 305 | + $part2 = (!empty($username_parts[1])) ?substr($username_parts[1], 0, 8) : "";  | 
                                                        |
| 306 | 306 | $part3 = rand(999, 9999);  | 
                                                        
| 307 | 307 | |
| 308 | - $username = $part1. $part2. $part3; //str_shuffle to randomly shuffle all characters  | 
                                                        |
| 308 | + $username = $part1.$part2.$part3; //str_shuffle to randomly shuffle all characters  | 
                                                        |
| 309 | 309 | |
| 310 | 310 | return $username;  | 
                                                        
| 311 | 311 | }  | 
                                                        
@@ -323,7 +323,7 @@ discard block  | 
                                                    ||
| 323 | 323 | $username = $request->email;  | 
                                                        
| 324 | 324 | }  | 
                                                        
| 325 | 325 |          else { | 
                                                        
| 326 | - $username = $this->generateUsername($request->firstname . ' ' . $request->lastname);  | 
                                                        |
| 326 | + $username = $this->generateUsername($request->firstname.' '.$request->lastname);  | 
                                                        |
| 327 | 327 | }  | 
                                                        
| 328 | 328 | |
| 329 | 329 | // update the user info  | 
                                                        
@@ -392,7 +392,7 @@ discard block  | 
                                                    ||
| 392 | 392 |      { | 
                                                        
| 393 | 393 | $student = Student::findOrFail($student);  | 
                                                        
| 394 | 394 | |
| 395 | -        if (! backpack_user()->isTeacher() && ! backpack_user()->can('enrollments.view')) { | 
                                                        |
| 395 | +        if (!backpack_user()->isTeacher() && !backpack_user()->can('enrollments.view')) { | 
                                                        |
| 396 | 396 | abort(403);  | 
                                                        
| 397 | 397 | }  | 
                                                        
| 398 | 398 | |