@@ -52,9 +52,9 @@ discard block |
||
| 52 | 52 | 'type' => 'select', |
| 53 | 53 | 'name' => 'student', |
| 54 | 54 | 'attribute' => 'name', |
| 55 | - 'searchLogic' => function ($query, $column, $searchTerm) { |
|
| 56 | - $query->orWhereHas('student', function ($q) use ($searchTerm) { |
|
| 57 | - $q->WhereHas('user', function ($q) use ($searchTerm) { |
|
| 55 | + 'searchLogic' => function($query, $column, $searchTerm) { |
|
| 56 | + $query->orWhereHas('student', function($q) use ($searchTerm) { |
|
| 57 | + $q->WhereHas('user', function($q) use ($searchTerm) { |
|
| 58 | 58 | $q->where('firstname', 'like', '%'.$searchTerm.'%') |
| 59 | 59 | ->orWhere('lastname', 'like', '%'.$searchTerm.'%') |
| 60 | 60 | ->orWhere('email', 'like', '%'.$searchTerm.'%') |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | 'label'=> __('No Result'), |
| 94 | 94 | ], |
| 95 | 95 | false, |
| 96 | - function () { |
|
| 96 | + function() { |
|
| 97 | 97 | CRUD::addClause('noResult'); |
| 98 | 98 | } |
| 99 | 99 | ); |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | 'label'=> __('Hide Parents'), |
| 106 | 106 | ], |
| 107 | 107 | false, |
| 108 | - function () { |
|
| 108 | + function() { |
|
| 109 | 109 | CRUD::addClause('real'); |
| 110 | 110 | } |
| 111 | 111 | ); |
@@ -114,16 +114,16 @@ discard block |
||
| 114 | 114 | 'name' => 'period_id', |
| 115 | 115 | 'type' => 'select2', |
| 116 | 116 | 'label'=> __('Period'), |
| 117 | - ], fn () => Period::all()->pluck('name', 'id')->toArray(), function ($value) { // if the filter is active |
|
| 117 | + ], fn() => Period::all()->pluck('name', 'id')->toArray(), function($value) { // if the filter is active |
|
| 118 | 118 | CRUD::addClause('period', $value); |
| 119 | 119 | }); |
| 120 | 120 | |
| 121 | - CRUD::addFilter([ // select2_multiple filter |
|
| 121 | + CRUD::addFilter([// select2_multiple filter |
|
| 122 | 122 | 'name' => 'result', |
| 123 | 123 | 'type' => 'select2', |
| 124 | 124 | 'label'=> __('Result'), |
| 125 | - ], fn () => ResultType::all()->pluck('name', 'id')->toArray(), function ($value) { // if the filter is active |
|
| 126 | - $this->crud->query = $this->crud->query->whereHas('result', function ($query) use ($value) { |
|
| 125 | + ], fn() => ResultType::all()->pluck('name', 'id')->toArray(), function($value) { // if the filter is active |
|
| 126 | + $this->crud->query = $this->crud->query->whereHas('result', function($query) use ($value) { |
|
| 127 | 127 | $query->where('result_type_id', $value); |
| 128 | 128 | }); |
| 129 | 129 | }); |
@@ -91,10 +91,10 @@ discard block |
||
| 91 | 91 | 'attribute' => 'lastname', |
| 92 | 92 | 'model' => \App\Models\User::class, |
| 93 | 93 | 'orderable' => true, |
| 94 | - 'orderLogic' => fn ($query, $column, $columnDirection) => $query->leftJoin('users', 'users.id', '=', 'students.id') |
|
| 94 | + 'orderLogic' => fn($query, $column, $columnDirection) => $query->leftJoin('users', 'users.id', '=', 'students.id') |
|
| 95 | 95 | ->orderBy('users.lastname', $columnDirection)->select('students.*'), |
| 96 | - 'searchLogic' => function ($query, $column, $searchTerm) { |
|
| 97 | - $query->orWhereHas('user', function ($q) use ($searchTerm) { |
|
| 96 | + 'searchLogic' => function($query, $column, $searchTerm) { |
|
| 97 | + $query->orWhereHas('user', function($q) use ($searchTerm) { |
|
| 98 | 98 | $q->where('lastname', 'like', '%'.$searchTerm.'%'); |
| 99 | 99 | }); |
| 100 | 100 | }, |
@@ -109,10 +109,10 @@ discard block |
||
| 109 | 109 | 'attribute' => 'firstname', |
| 110 | 110 | 'model' => \App\Models\User::class, |
| 111 | 111 | 'orderable' => true, |
| 112 | - 'orderLogic' => fn ($query, $column, $columnDirection) => $query->leftJoin('users', 'users.id', '=', 'students.id') |
|
| 112 | + 'orderLogic' => fn($query, $column, $columnDirection) => $query->leftJoin('users', 'users.id', '=', 'students.id') |
|
| 113 | 113 | ->orderBy('users.firstname', $columnDirection)->select('students.*'), |
| 114 | - 'searchLogic' => function ($query, $column, $searchTerm) { |
|
| 115 | - $query->orWhereHas('user', function ($q) use ($searchTerm) { |
|
| 114 | + 'searchLogic' => function($query, $column, $searchTerm) { |
|
| 115 | + $query->orWhereHas('user', function($q) use ($searchTerm) { |
|
| 116 | 116 | $q->where('firstname', 'like', '%'.$searchTerm.'%'); |
| 117 | 117 | }); |
| 118 | 118 | }, |
@@ -126,10 +126,10 @@ discard block |
||
| 126 | 126 | 'attribute' => 'email', |
| 127 | 127 | 'model' => \App\Models\User::class, |
| 128 | 128 | 'orderable' => true, |
| 129 | - 'orderLogic' => fn ($query, $column, $columnDirection) => $query->leftJoin('users', 'users.id', '=', 'students.id') |
|
| 129 | + 'orderLogic' => fn($query, $column, $columnDirection) => $query->leftJoin('users', 'users.id', '=', 'students.id') |
|
| 130 | 130 | ->orderBy('users.email', $columnDirection)->select('students.*'), |
| 131 | - 'searchLogic' => function ($query, $column, $searchTerm) { |
|
| 132 | - $query->orWhereHas('user', function ($q) use ($searchTerm) { |
|
| 131 | + 'searchLogic' => function($query, $column, $searchTerm) { |
|
| 132 | + $query->orWhereHas('user', function($q) use ($searchTerm) { |
|
| 133 | 133 | $q->where('email', 'like', '%'.$searchTerm.'%'); |
| 134 | 134 | }); |
| 135 | 135 | }, |
@@ -175,25 +175,25 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | ]); |
| 177 | 177 | |
| 178 | - CRUD::addFilter([ // select2 filter |
|
| 178 | + CRUD::addFilter([// select2 filter |
|
| 179 | 179 | 'name' => 'enrolled', |
| 180 | 180 | 'type' => 'select2', |
| 181 | 181 | 'label'=> __('Is Enrolled in'), |
| 182 | - ], fn () => Period::all()->pluck('name', 'id')->toArray(), function ($value) { // if the filter is active |
|
| 183 | - $this->crud->query = $this->crud->query->whereHas('enrollments', fn ($query) => $query->whereHas('course', function ($q) use ($value) { |
|
| 182 | + ], fn() => Period::all()->pluck('name', 'id')->toArray(), function($value) { // if the filter is active |
|
| 183 | + $this->crud->query = $this->crud->query->whereHas('enrollments', fn($query) => $query->whereHas('course', function($q) use ($value) { |
|
| 184 | 184 | $q->where('period_id', $value); |
| 185 | 185 | })); |
| 186 | 186 | }, |
| 187 | - function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 187 | + function() { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 188 | 188 | }); |
| 189 | 189 | |
| 190 | - CRUD::addFilter([ // select2_multiple filter |
|
| 190 | + CRUD::addFilter([// select2_multiple filter |
|
| 191 | 191 | 'name' => 'notenrolled', |
| 192 | 192 | 'type' => 'select2_multiple', |
| 193 | 193 | 'label'=> __('Is Not Enrolled in'), |
| 194 | - ], fn () => Period::all()->pluck('name', 'id')->toArray(), function ($values) { // if the filter is active |
|
| 194 | + ], fn() => Period::all()->pluck('name', 'id')->toArray(), function($values) { // if the filter is active |
|
| 195 | 195 | foreach (json_decode($values, null, 512, JSON_THROW_ON_ERROR) as $value) { |
| 196 | - $this->crud->query = $this->crud->query->whereDoesntHave('enrollments', fn ($query) => $query->whereHas('course', function ($q) use ($value) { |
|
| 196 | + $this->crud->query = $this->crud->query->whereDoesntHave('enrollments', fn($query) => $query->whereHas('course', function($q) use ($value) { |
|
| 197 | 197 | $q->where('period_id', $value); |
| 198 | 198 | })); |
| 199 | 199 | } |
@@ -204,8 +204,8 @@ discard block |
||
| 204 | 204 | 'type' => 'select2', |
| 205 | 205 | 'label'=> __('New In'), |
| 206 | 206 | ], |
| 207 | - fn () => Period::all()->pluck('name', 'id')->toArray(), |
|
| 208 | - function ($value) { // if the filter is active |
|
| 207 | + fn() => Period::all()->pluck('name', 'id')->toArray(), |
|
| 208 | + function($value) { // if the filter is active |
|
| 209 | 209 | CRUD::addClause('newInPeriod', $value); |
| 210 | 210 | } |
| 211 | 211 | ); |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | 'name' => 'institution_id', |
| 216 | 216 | 'type' => 'select2', |
| 217 | 217 | 'label' => __('Institution'), |
| 218 | - ], fn () => Institution::all()->pluck('name', 'id')->toArray(), function ($value) { // if the filter is active |
|
| 218 | + ], fn() => Institution::all()->pluck('name', 'id')->toArray(), function($value) { // if the filter is active |
|
| 219 | 219 | $this->crud->addClause('where', 'institution_id', $value); |
| 220 | 220 | }); |
| 221 | 221 | |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | 'name' => 'status_type_id', |
| 224 | 224 | 'type' => 'select2', |
| 225 | 225 | 'label' => __('Lead Status'), |
| 226 | - ], fn () => LeadType::all()->pluck('name', 'id')->toArray(), function ($value) { |
|
| 226 | + ], fn() => LeadType::all()->pluck('name', 'id')->toArray(), function($value) { |
|
| 227 | 227 | if ($value === '4') { |
| 228 | 228 | $this->crud->query = $this->crud->query->where('lead_type_id', $value)->orWhere('lead_type_id', null); |
| 229 | 229 | } else { |
@@ -339,8 +339,8 @@ discard block |
||
| 339 | 339 | $username_parts = array_filter(explode(' ', strtolower($fullName))); |
| 340 | 340 | $username_parts = array_slice($username_parts, -2); |
| 341 | 341 | |
| 342 | - $part1 = (! empty($username_parts[0])) ? substr($username_parts[0], 0, 3) : ''; |
|
| 343 | - $part2 = (! empty($username_parts[1])) ? substr($username_parts[1], 0, 8) : ''; |
|
| 342 | + $part1 = (!empty($username_parts[0])) ? substr($username_parts[0], 0, 3) : ''; |
|
| 343 | + $part2 = (!empty($username_parts[1])) ? substr($username_parts[1], 0, 8) : ''; |
|
| 344 | 344 | $part3 = random_int(999, 9999); |
| 345 | 345 | |
| 346 | 346 | $username = $part1.$part2.$part3; //str_shuffle to randomly shuffle all characters |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | { |
| 429 | 429 | $student = Student::findOrFail($student); |
| 430 | 430 | |
| 431 | - if (! backpack_user()->isTeacher() && ! backpack_user()->can('enrollments.view')) { |
|
| 431 | + if (!backpack_user()->isTeacher() && !backpack_user()->can('enrollments.view')) { |
|
| 432 | 432 | abort(403); |
| 433 | 433 | } |
| 434 | 434 | |
@@ -46,10 +46,10 @@ discard block |
||
| 46 | 46 | 'attribute' => 'lastname', |
| 47 | 47 | 'model' => \App\Models\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 |
||
| 64 | 64 | 'attribute' => 'firstname', |
| 65 | 65 | 'model' => \App\Models\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 |
||
| 81 | 81 | 'attribute' => 'email', |
| 82 | 82 | 'model' => \App\Models\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 |
||
| 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 | $username = $part1.$part2.$part3; //str_shuffle to randomly shuffle all characters |
@@ -34,7 +34,7 @@ discard block |
||
| 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 |
||
| 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', |
@@ -67,23 +67,23 @@ discard block |
||
| 67 | 67 | ], |
| 68 | 68 | ]); |
| 69 | 69 | |
| 70 | - CRUD::addFilter([ // select2 filter |
|
| 70 | + CRUD::addFilter([// select2 filter |
|
| 71 | 71 | 'name' => 'teacher_id', |
| 72 | 72 | 'type' => 'select2', |
| 73 | 73 | 'label'=> __('Teacher'), |
| 74 | - ], fn () => Teacher::all()->pluck('name', 'id')->toArray(), function ($value) { // if the filter is active |
|
| 74 | + ], fn() => Teacher::all()->pluck('name', 'id')->toArray(), function($value) { // if the filter is active |
|
| 75 | 75 | CRUD::addClause('where', 'teacher_id', $value); |
| 76 | 76 | }, |
| 77 | - function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 77 | + function() { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 78 | 78 | }); |
| 79 | 79 | |
| 80 | - CRUD::addFilter([ // daterange filter |
|
| 80 | + CRUD::addFilter([// daterange filter |
|
| 81 | 81 | 'type' => 'date_range', |
| 82 | 82 | 'name' => 'from_to', |
| 83 | 83 | 'label'=> __('Date range'), |
| 84 | 84 | ], |
| 85 | 85 | false, |
| 86 | - function ($value) { // if the filter is active, apply these constraints |
|
| 86 | + function($value) { // if the filter is active, apply these constraints |
|
| 87 | 87 | $dates = json_decode($value, null, 512, JSON_THROW_ON_ERROR); |
| 88 | 88 | CRUD::addClause('where', 'date', '>=', $dates->from); |
| 89 | 89 | CRUD::addClause('where', 'date', '<=', $dates->to.' 23:59:59'); |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | 'model' => LeaveType::class, |
| 116 | 116 | ], |
| 117 | 117 | |
| 118 | - [ // date_range |
|
| 118 | + [// date_range |
|
| 119 | 119 | 'name' => ['start_date', 'end_date'], // db columns for start_date & end_date |
| 120 | 120 | 'label' => 'Event Date Range', |
| 121 | 121 | 'type' => 'date_range', |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | 'model' => LeaveType::class, |
| 160 | 160 | ], |
| 161 | 161 | |
| 162 | - [ // datepicker |
|
| 162 | + [// datepicker |
|
| 163 | 163 | 'name' => 'date', |
| 164 | 164 | 'label' => 'Event Date', |
| 165 | 165 | 'type' => 'date', |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | public function skills() |
| 202 | 202 | { |
| 203 | - return $this->evaluationType?->skills()->orderBy('order'); |
|
| 203 | + return $this->evaluationType ? ->skills()->orderBy('order'); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | public function books() |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | */ |
| 226 | 226 | public function getPendingAttendanceAttribute() |
| 227 | 227 | { |
| 228 | - $events = Event::where(function ($query) { |
|
| 228 | + $events = Event::where(function($query) { |
|
| 229 | 229 | $query->where('course_id', $this->id); |
| 230 | 230 | $query->where('exempt_attendance', '!=', true); |
| 231 | 231 | $query->where('exempt_attendance', '!=', 1); |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | foreach ($courseTimes as $courseTime) { |
| 359 | 359 | $initial = $daysInitials[$courseTime->day]; |
| 360 | 360 | |
| 361 | - if (! isset($parsedCourseTimes[$initial])) { |
|
| 361 | + if (!isset($parsedCourseTimes[$initial])) { |
|
| 362 | 362 | $parsedCourseTimes[$initial] = []; |
| 363 | 363 | } |
| 364 | 364 | |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | public function getCourseTeacherNameAttribute() |
| 406 | 406 | { |
| 407 | 407 | if ($this->teacher_id) { |
| 408 | - return $this->teacher?->name; |
|
| 408 | + return $this->teacher ? ->name; |
|
| 409 | 409 | } else { |
| 410 | 410 | return '-'; |
| 411 | 411 | } |
@@ -438,11 +438,11 @@ discard block |
||
| 438 | 438 | |
| 439 | 439 | public function getAcceptsNewStudentsAttribute(): bool |
| 440 | 440 | { |
| 441 | - if (! $this->spots || $this->spots == 0) { |
|
| 441 | + if (!$this->spots || $this->spots == 0) { |
|
| 442 | 442 | return true; |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - return $this->spots - $this->enrollments()->whereIn('status_id', [1,2])->count() > 0; |
|
| 445 | + return $this->spots - $this->enrollments()->whereIn('status_id', [1, 2])->count() > 0; |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | public function getTakesAttendanceAttribute(): bool |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | |
| 462 | 462 | public function eventsWithExpectedAttendance() |
| 463 | 463 | { |
| 464 | - return $this->events()->where(function ($query) { |
|
| 464 | + return $this->events()->where(function($query) { |
|
| 465 | 465 | $query->where('exempt_attendance', '!=', true); |
| 466 | 466 | $query->where('exempt_attendance', '!=', 1); |
| 467 | 467 | $query->orWhereNull('exempt_attendance'); |