@@ -96,10 +96,10 @@ discard block |
||
| 96 | 96 | 'attribute' => 'lastname', |
| 97 | 97 | 'model' => User::class, |
| 98 | 98 | 'orderable' => true, |
| 99 | - 'orderLogic' => fn ($query, $column, $columnDirection) => $query->leftJoin('users', 'users.id', '=', 'students.id') |
|
| 99 | + 'orderLogic' => fn($query, $column, $columnDirection) => $query->leftJoin('users', 'users.id', '=', 'students.id') |
|
| 100 | 100 | ->orderBy('users.lastname', $columnDirection)->select('students.*'), |
| 101 | - 'searchLogic' => function ($query, $column, $searchTerm) { |
|
| 102 | - $query->orWhereHas('user', function ($q) use ($searchTerm) { |
|
| 101 | + 'searchLogic' => function($query, $column, $searchTerm) { |
|
| 102 | + $query->orWhereHas('user', function($q) use ($searchTerm) { |
|
| 103 | 103 | $q->where('lastname', 'like', '%'.$searchTerm.'%'); |
| 104 | 104 | }); |
| 105 | 105 | }, |
@@ -114,10 +114,10 @@ discard block |
||
| 114 | 114 | 'attribute' => 'firstname', |
| 115 | 115 | 'model' => User::class, |
| 116 | 116 | 'orderable' => true, |
| 117 | - 'orderLogic' => fn ($query, $column, $columnDirection) => $query->leftJoin('users', 'users.id', '=', 'students.id') |
|
| 117 | + 'orderLogic' => fn($query, $column, $columnDirection) => $query->leftJoin('users', 'users.id', '=', 'students.id') |
|
| 118 | 118 | ->orderBy('users.firstname', $columnDirection)->select('students.*'), |
| 119 | - 'searchLogic' => function ($query, $column, $searchTerm) { |
|
| 120 | - $query->orWhereHas('user', function ($q) use ($searchTerm) { |
|
| 119 | + 'searchLogic' => function($query, $column, $searchTerm) { |
|
| 120 | + $query->orWhereHas('user', function($q) use ($searchTerm) { |
|
| 121 | 121 | $q->where('firstname', 'like', '%'.$searchTerm.'%'); |
| 122 | 122 | }); |
| 123 | 123 | }, |
@@ -131,10 +131,10 @@ discard block |
||
| 131 | 131 | 'attribute' => 'email', |
| 132 | 132 | 'model' => User::class, |
| 133 | 133 | 'orderable' => true, |
| 134 | - 'orderLogic' => fn ($query, $column, $columnDirection) => $query->leftJoin('users', 'users.id', '=', 'students.id') |
|
| 134 | + 'orderLogic' => fn($query, $column, $columnDirection) => $query->leftJoin('users', 'users.id', '=', 'students.id') |
|
| 135 | 135 | ->orderBy('users.email', $columnDirection)->select('students.*'), |
| 136 | - 'searchLogic' => function ($query, $column, $searchTerm) { |
|
| 137 | - $query->orWhereHas('user', function ($q) use ($searchTerm) { |
|
| 136 | + 'searchLogic' => function($query, $column, $searchTerm) { |
|
| 137 | + $query->orWhereHas('user', function($q) use ($searchTerm) { |
|
| 138 | 138 | $q->where('email', 'like', '%'.$searchTerm.'%'); |
| 139 | 139 | }); |
| 140 | 140 | }, |
@@ -181,28 +181,28 @@ discard block |
||
| 181 | 181 | ]); |
| 182 | 182 | |
| 183 | 183 | CRUD::addFilter( |
| 184 | - [ // select2 filter |
|
| 184 | + [// select2 filter |
|
| 185 | 185 | 'name' => 'enrolled', |
| 186 | 186 | 'type' => 'select2', |
| 187 | 187 | 'label' => __('Is Enrolled in'), |
| 188 | 188 | ], |
| 189 | - fn () => Period::all()->pluck('name', 'id')->toArray(), |
|
| 190 | - function ($value) { |
|
| 191 | - $this->crud->query = $this->crud->query->whereHas('enrollments', fn ($query) => $query->whereHas('course', function ($q) use ($value) { |
|
| 189 | + fn() => Period::all()->pluck('name', 'id')->toArray(), |
|
| 190 | + function($value) { |
|
| 191 | + $this->crud->query = $this->crud->query->whereHas('enrollments', fn($query) => $query->whereHas('course', function($q) use ($value) { |
|
| 192 | 192 | $q->where('period_id', $value); |
| 193 | 193 | })); |
| 194 | 194 | }, |
| 195 | - function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 195 | + function() { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 196 | 196 | } |
| 197 | 197 | ); |
| 198 | 198 | |
| 199 | - CRUD::addFilter([ // select2_multiple filter |
|
| 199 | + CRUD::addFilter([// select2_multiple filter |
|
| 200 | 200 | 'name' => 'notenrolled', |
| 201 | 201 | 'type' => 'select2_multiple', |
| 202 | 202 | 'label' => __('Is Not Enrolled in'), |
| 203 | - ], fn () => Period::all()->pluck('name', 'id')->toArray(), function ($values) { |
|
| 203 | + ], fn() => Period::all()->pluck('name', 'id')->toArray(), function($values) { |
|
| 204 | 204 | foreach (json_decode($values, null, 512, JSON_THROW_ON_ERROR) as $value) { |
| 205 | - $this->crud->query = $this->crud->query->whereDoesntHave('enrollments', fn ($query) => $query->whereHas('course', function ($q) use ($value) { |
|
| 205 | + $this->crud->query = $this->crud->query->whereDoesntHave('enrollments', fn($query) => $query->whereHas('course', function($q) use ($value) { |
|
| 206 | 206 | $q->where('period_id', $value); |
| 207 | 207 | })); |
| 208 | 208 | } |
@@ -214,8 +214,8 @@ discard block |
||
| 214 | 214 | 'type' => 'select2', |
| 215 | 215 | 'label' => __('New In'), |
| 216 | 216 | ], |
| 217 | - fn () => Period::all()->pluck('name', 'id')->toArray(), |
|
| 218 | - function ($value) { |
|
| 217 | + fn() => Period::all()->pluck('name', 'id')->toArray(), |
|
| 218 | + function($value) { |
|
| 219 | 219 | CRUD::addClause('newInPeriod', $value); |
| 220 | 220 | } |
| 221 | 221 | ); |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | 'name' => 'institution_id', |
| 226 | 226 | 'type' => 'select2', |
| 227 | 227 | 'label' => __('Institution'), |
| 228 | - ], fn () => Institution::all()->pluck('name', 'id')->toArray(), function ($value) { |
|
| 228 | + ], fn() => Institution::all()->pluck('name', 'id')->toArray(), function($value) { |
|
| 229 | 229 | $this->crud->addClause('where', 'institution_id', $value); |
| 230 | 230 | }); |
| 231 | 231 | |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | 'name' => 'lead_type_id', |
| 234 | 234 | 'type' => 'select2', |
| 235 | 235 | 'label' => __('Lead Status'), |
| 236 | - ], fn () => LeadType::all()->pluck('name', 'id')->toArray(), function ($value) { |
|
| 236 | + ], fn() => LeadType::all()->pluck('name', 'id')->toArray(), function($value) { |
|
| 237 | 237 | if ($value === '4') { |
| 238 | 238 | $this->crud->query = $this->crud->query->where('lead_type_id', $value)->orWhere('lead_type_id', null); |
| 239 | 239 | } else { |
@@ -366,8 +366,8 @@ discard block |
||
| 366 | 366 | $username_parts = array_filter(explode(' ', strtolower($fullName))); |
| 367 | 367 | $username_parts = array_slice($username_parts, -2); |
| 368 | 368 | |
| 369 | - $part1 = (! empty($username_parts[0])) ? substr($username_parts[0], 0, 3) : ''; |
|
| 370 | - $part2 = (! empty($username_parts[1])) ? substr($username_parts[1], 0, 8) : ''; |
|
| 369 | + $part1 = (!empty($username_parts[0])) ? substr($username_parts[0], 0, 3) : ''; |
|
| 370 | + $part2 = (!empty($username_parts[1])) ? substr($username_parts[1], 0, 8) : ''; |
|
| 371 | 371 | $part3 = random_int(999, 9999); |
| 372 | 372 | |
| 373 | 373 | //str_shuffle to randomly shuffle all characters |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | { |
| 456 | 456 | $student = Student::findOrFail($student); |
| 457 | 457 | |
| 458 | - if (! backpack_user()->isTeacher() && ! backpack_user()->can('enrollments.view')) { |
|
| 458 | + if (!backpack_user()->isTeacher() && !backpack_user()->can('enrollments.view')) { |
|
| 459 | 459 | abort(403); |
| 460 | 460 | } |
| 461 | 461 | |
@@ -45,8 +45,8 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | public function scopeEnrolled($query) |
| 47 | 47 | { |
| 48 | - return $query->whereHas('enrollments', function ($q) { |
|
| 49 | - return $q->whereHas('course', function ($q) { |
|
| 48 | + return $query->whereHas('enrollments', function($q) { |
|
| 49 | + return $q->whereHas('course', function($q) { |
|
| 50 | 50 | return $q->where('period_id', Period::get_default_period()->id); |
| 51 | 51 | }); |
| 52 | 52 | }); |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | return $this->hasMany(Attendance::class) |
| 85 | 85 | ->where('attendance_type_id', 4) // absence |
| 86 | - ->whereHas('event', fn ($q) => $q->whereHas('course', fn ($c) => $c->where('period_id', $period->id))); |
|
| 86 | + ->whereHas('event', fn($q) => $q->whereHas('course', fn($c) => $c->where('period_id', $period->id))); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | public function periodAttendance(Period $period = null) |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | return $this->hasMany(Attendance::class) |
| 96 | - ->whereHas('event', fn ($q) => $q->whereHas('course', fn ($c) => $c->where('period_id', $period->id))); |
|
| 96 | + ->whereHas('event', fn($q) => $q->whereHas('course', fn($c) => $c->where('period_id', $period->id))); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | public function contacts() |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | |
| 155 | 155 | public function getEmailAttribute(): ?string |
| 156 | 156 | { |
| 157 | - return $this?->user?->email; |
|
| 157 | + return $this ? ->user ? ->email; |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | public function getNameAttribute(): string |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | public function getIsEnrolledAttribute() |
| 176 | 176 | { |
| 177 | 177 | // if the student is currently enrolled |
| 178 | - if ($this->enrollments()->whereHas('course', fn ($q) => $q->where('period_id', Period::get_default_period()->id))->count() > 0) { |
|
| 178 | + if ($this->enrollments()->whereHas('course', fn($q) => $q->where('period_id', Period::get_default_period()->id))->count() > 0) { |
|
| 179 | 179 | return 1; |
| 180 | 180 | } |
| 181 | 181 | |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | |
| 275 | 275 | public function getImageAttribute(): ?string |
| 276 | 276 | { |
| 277 | - return $this->getMedia('profile-picture')->last()?->getUrl('thumb'); |
|
| 277 | + return $this->getMedia('profile-picture')->last() ? ->getUrl('thumb'); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | public function setImageAttribute($value) |