@@ -53,12 +53,12 @@ |
||
| 53 | 53 | |
| 54 | 54 | View::composer( |
| 55 | 55 | ['partials.create_new_contact', 'students.edit-contact'], |
| 56 | - function ($view) { |
|
| 56 | + function($view) { |
|
| 57 | 57 | $view->with('contact_types', ContactRelationship::all()); |
| 58 | 58 | } |
| 59 | 59 | ); |
| 60 | 60 | |
| 61 | - View::composer('partials.add_book_to_student', function ($view) { |
|
| 61 | + View::composer('partials.add_book_to_student', function($view) { |
|
| 62 | 62 | $view->with('books', Book::all()); |
| 63 | 63 | $view->with('statuses', EnrollmentStatusType::all()); |
| 64 | 64 | }); |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | 'label' => __('Due Date'), |
| 51 | 51 | ], |
| 52 | 52 | false, |
| 53 | - function ($value) { // if the filter is active, apply these constraints |
|
| 53 | + function($value) { // if the filter is active, apply these constraints |
|
| 54 | 54 | $this->crud->addClause('where', 'date', '>=', Carbon::parse($value)->firstOfMonth()); |
| 55 | 55 | $this->crud->addClause('where', 'date', '<=', Carbon::parse($value)->lastOfMonth()); |
| 56 | 56 | } |
@@ -92,11 +92,11 @@ discard block |
||
| 92 | 92 | { |
| 93 | 93 | $payment = Payment::findOrFail($id); |
| 94 | 94 | |
| 95 | - if (! backpack_user()->can('enrollments.edit')) { |
|
| 95 | + if (!backpack_user()->can('enrollments.edit')) { |
|
| 96 | 96 | abort(403); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - if (! $payment->invoice) { |
|
| 99 | + if (!$payment->invoice) { |
|
| 100 | 100 | abort(404, 'No enrollment found for this payment'); |
| 101 | 101 | } |
| 102 | 102 | |
@@ -188,7 +188,7 @@ |
||
| 188 | 188 | })); |
| 189 | 189 | }, |
| 190 | 190 | function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
| 191 | - } |
|
| 191 | + } |
|
| 192 | 192 | ); |
| 193 | 193 | |
| 194 | 194 | CRUD::addFilter([ // select2_multiple filter |
@@ -91,10 +91,10 @@ discard block |
||
| 91 | 91 | 'attribute' => 'lastname', |
| 92 | 92 | 'model' => 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' => 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' => 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 | }, |
@@ -176,28 +176,28 @@ discard block |
||
| 176 | 176 | ]); |
| 177 | 177 | |
| 178 | 178 | CRUD::addFilter( |
| 179 | - [ // select2 filter |
|
| 179 | + [// select2 filter |
|
| 180 | 180 | 'name' => 'enrolled', |
| 181 | 181 | 'type' => 'select2', |
| 182 | 182 | 'label'=> __('Is Enrolled in'), |
| 183 | 183 | ], |
| 184 | - fn () => Period::all()->pluck('name', 'id')->toArray(), |
|
| 185 | - function ($value) { // if the filter is active |
|
| 186 | - $this->crud->query = $this->crud->query->whereHas('enrollments', fn ($query) => $query->whereHas('course', function ($q) use ($value) { |
|
| 184 | + fn() => Period::all()->pluck('name', 'id')->toArray(), |
|
| 185 | + function($value) { // if the filter is active |
|
| 186 | + $this->crud->query = $this->crud->query->whereHas('enrollments', fn($query) => $query->whereHas('course', function($q) use ($value) { |
|
| 187 | 187 | $q->where('period_id', $value); |
| 188 | 188 | })); |
| 189 | 189 | }, |
| 190 | - function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 190 | + function() { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 191 | 191 | } |
| 192 | 192 | ); |
| 193 | 193 | |
| 194 | - CRUD::addFilter([ // select2_multiple filter |
|
| 194 | + CRUD::addFilter([// select2_multiple filter |
|
| 195 | 195 | 'name' => 'notenrolled', |
| 196 | 196 | 'type' => 'select2_multiple', |
| 197 | 197 | 'label'=> __('Is Not Enrolled in'), |
| 198 | - ], fn () => Period::all()->pluck('name', 'id')->toArray(), function ($values) { // if the filter is active |
|
| 198 | + ], fn() => Period::all()->pluck('name', 'id')->toArray(), function($values) { // if the filter is active |
|
| 199 | 199 | foreach (json_decode($values, null, 512, JSON_THROW_ON_ERROR) as $value) { |
| 200 | - $this->crud->query = $this->crud->query->whereDoesntHave('enrollments', fn ($query) => $query->whereHas('course', function ($q) use ($value) { |
|
| 200 | + $this->crud->query = $this->crud->query->whereDoesntHave('enrollments', fn($query) => $query->whereHas('course', function($q) use ($value) { |
|
| 201 | 201 | $q->where('period_id', $value); |
| 202 | 202 | })); |
| 203 | 203 | } |
@@ -209,8 +209,8 @@ discard block |
||
| 209 | 209 | 'type' => 'select2', |
| 210 | 210 | 'label'=> __('New In'), |
| 211 | 211 | ], |
| 212 | - fn () => Period::all()->pluck('name', 'id')->toArray(), |
|
| 213 | - function ($value) { // if the filter is active |
|
| 212 | + fn() => Period::all()->pluck('name', 'id')->toArray(), |
|
| 213 | + function($value) { // if the filter is active |
|
| 214 | 214 | CRUD::addClause('newInPeriod', $value); |
| 215 | 215 | } |
| 216 | 216 | ); |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | 'name' => 'institution_id', |
| 221 | 221 | 'type' => 'select2', |
| 222 | 222 | 'label' => __('Institution'), |
| 223 | - ], fn () => Institution::all()->pluck('name', 'id')->toArray(), function ($value) { // if the filter is active |
|
| 223 | + ], fn() => Institution::all()->pluck('name', 'id')->toArray(), function($value) { // if the filter is active |
|
| 224 | 224 | $this->crud->addClause('where', 'institution_id', $value); |
| 225 | 225 | }); |
| 226 | 226 | |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | 'name' => 'status_type_id', |
| 229 | 229 | 'type' => 'select2', |
| 230 | 230 | 'label' => __('Lead Status'), |
| 231 | - ], fn () => LeadType::all()->pluck('name', 'id')->toArray(), function ($value) { |
|
| 231 | + ], fn() => LeadType::all()->pluck('name', 'id')->toArray(), function($value) { |
|
| 232 | 232 | if ($value === '4') { |
| 233 | 233 | $this->crud->query = $this->crud->query->where('lead_type_id', $value)->orWhere('lead_type_id', null); |
| 234 | 234 | } else { |
@@ -344,8 +344,8 @@ discard block |
||
| 344 | 344 | $username_parts = array_filter(explode(' ', strtolower($fullName))); |
| 345 | 345 | $username_parts = array_slice($username_parts, -2); |
| 346 | 346 | |
| 347 | - $part1 = (! empty($username_parts[0])) ? substr($username_parts[0], 0, 3) : ''; |
|
| 348 | - $part2 = (! empty($username_parts[1])) ? substr($username_parts[1], 0, 8) : ''; |
|
| 347 | + $part1 = (!empty($username_parts[0])) ? substr($username_parts[0], 0, 3) : ''; |
|
| 348 | + $part2 = (!empty($username_parts[1])) ? substr($username_parts[1], 0, 8) : ''; |
|
| 349 | 349 | $part3 = random_int(999, 9999); |
| 350 | 350 | |
| 351 | 351 | $username = $part1.$part2.$part3; //str_shuffle to randomly shuffle all characters |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | { |
| 434 | 434 | $student = Student::findOrFail($student); |
| 435 | 435 | |
| 436 | - if (! backpack_user()->isTeacher() && ! backpack_user()->can('enrollments.view')) { |
|
| 436 | + if (!backpack_user()->isTeacher() && !backpack_user()->can('enrollments.view')) { |
|
| 437 | 437 | abort(403); |
| 438 | 438 | } |
| 439 | 439 | |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | 'attribute' => 'lastname', |
| 44 | 44 | 'label' => __('Last Name'), |
| 45 | 45 | 'type' => 'relationship', |
| 46 | - 'searchLogic' => function ($query, $column, $searchTerm) { |
|
| 47 | - $query->orWhereHas('enrollment', function ($q) use ($searchTerm) { |
|
| 48 | - $q->whereHas('user', function ($q) use ($searchTerm) { |
|
| 46 | + 'searchLogic' => function($query, $column, $searchTerm) { |
|
| 47 | + $query->orWhereHas('enrollment', function($q) use ($searchTerm) { |
|
| 48 | + $q->whereHas('user', function($q) use ($searchTerm) { |
|
| 49 | 49 | $q->where('lastname', 'like', '%'.$searchTerm.'%'); |
| 50 | 50 | }); |
| 51 | 51 | }); |
@@ -58,9 +58,9 @@ discard block |
||
| 58 | 58 | 'attribute' => 'firstname', |
| 59 | 59 | 'label' => __('First Name'), |
| 60 | 60 | 'type' => 'relationship', |
| 61 | - 'searchLogic' => function ($query, $column, $searchTerm) { |
|
| 62 | - $query->orWhereHas('enrollment', function ($q) use ($searchTerm) { |
|
| 63 | - $q->whereHas('user', function ($q) use ($searchTerm) { |
|
| 61 | + 'searchLogic' => function($query, $column, $searchTerm) { |
|
| 62 | + $query->orWhereHas('enrollment', function($q) use ($searchTerm) { |
|
| 63 | + $q->whereHas('user', function($q) use ($searchTerm) { |
|
| 64 | 64 | $q->where('firstname', 'like', '%'.$searchTerm.'%'); |
| 65 | 65 | }); |
| 66 | 66 | }); |
@@ -73,9 +73,9 @@ discard block |
||
| 73 | 73 | 'attribute' => 'email', |
| 74 | 74 | 'label' => __('Email'), |
| 75 | 75 | 'type' => 'relationship', |
| 76 | - 'searchLogic' => function ($query, $column, $searchTerm) { |
|
| 77 | - $query->orWhereHas('enrollment', function ($q) use ($searchTerm) { |
|
| 78 | - $q->whereHas('user', function ($q) use ($searchTerm) { |
|
| 76 | + 'searchLogic' => function($query, $column, $searchTerm) { |
|
| 77 | + $query->orWhereHas('enrollment', function($q) use ($searchTerm) { |
|
| 78 | + $q->whereHas('user', function($q) use ($searchTerm) { |
|
| 79 | 79 | $q->where('email', 'like', '%'.$searchTerm.'%'); |
| 80 | 80 | }); |
| 81 | 81 | }); |
@@ -107,11 +107,11 @@ discard block |
||
| 107 | 107 | 'type' => 'select2', |
| 108 | 108 | 'label'=> __('Status'), |
| 109 | 109 | ], |
| 110 | - fn () => [ |
|
| 110 | + fn() => [ |
|
| 111 | 111 | 1 => __('Pending'), |
| 112 | 112 | 2 => __('Paid'), |
| 113 | 113 | ], |
| 114 | - function ($value) { // if the filter is active |
|
| 114 | + function($value) { // if the filter is active |
|
| 115 | 115 | CRUD::addClause('status', $value); |
| 116 | 116 | } |
| 117 | 117 | ); |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | CRUD::addClause('internal'); |
| 55 | 55 | $permissions = backpack_user()->getAllPermissions(); |
| 56 | 56 | |
| 57 | - if (! $permissions->contains('name', 'courses.edit')) { |
|
| 57 | + if (!$permissions->contains('name', 'courses.edit')) { |
|
| 58 | 58 | CRUD::denyAccess(['update', 'create']); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | CRUD::addButtonFromView('line', 'children_badge', 'children_badge', 'beginning'); |
| 66 | 66 | |
| 67 | - if (! $permissions->contains('name', 'courses.delete')) { |
|
| 67 | + if (!$permissions->contains('name', 'courses.delete')) { |
|
| 68 | 68 | CRUD::denyAccess(['delete']); |
| 69 | 69 | } |
| 70 | 70 | |
@@ -188,12 +188,12 @@ discard block |
||
| 188 | 188 | 'type' => 'select2', |
| 189 | 189 | 'label'=> __('Rhythm'), |
| 190 | 190 | ], |
| 191 | - fn () => Rhythm::all()->pluck('name', 'id')->toArray(), |
|
| 192 | - function ($value) { |
|
| 191 | + fn() => Rhythm::all()->pluck('name', 'id')->toArray(), |
|
| 192 | + function($value) { |
|
| 193 | 193 | // if the filter is active |
| 194 | 194 | CRUD::addClause('where', 'rhythm_id', $value); |
| 195 | 195 | }, |
| 196 | - function () { |
|
| 196 | + function() { |
|
| 197 | 197 | // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
| 198 | 198 | } |
| 199 | 199 | ); |
@@ -204,12 +204,12 @@ discard block |
||
| 204 | 204 | 'type' => 'select2', |
| 205 | 205 | 'label'=> __('Teacher'), |
| 206 | 206 | ], |
| 207 | - fn () => Teacher::all()->pluck('name', 'id')->toArray(), |
|
| 208 | - function ($value) { |
|
| 207 | + fn() => Teacher::all()->pluck('name', 'id')->toArray(), |
|
| 208 | + function($value) { |
|
| 209 | 209 | // if the filter is active |
| 210 | 210 | CRUD::addClause('where', 'teacher_id', $value); |
| 211 | 211 | }, |
| 212 | - function () { |
|
| 212 | + function() { |
|
| 213 | 213 | // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
| 214 | 214 | } |
| 215 | 215 | ); |
@@ -220,12 +220,12 @@ discard block |
||
| 220 | 220 | 'type' => 'select2', |
| 221 | 221 | 'label'=> __('Level'), |
| 222 | 222 | ], |
| 223 | - fn () => Level::all()->pluck('name', 'id')->toArray(), |
|
| 224 | - function ($value) { |
|
| 223 | + fn() => Level::all()->pluck('name', 'id')->toArray(), |
|
| 224 | + function($value) { |
|
| 225 | 225 | // if the filter is active |
| 226 | 226 | CRUD::addClause('where', 'level_id', $value); |
| 227 | 227 | }, |
| 228 | - function () { |
|
| 228 | + function() { |
|
| 229 | 229 | // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
| 230 | 230 | } |
| 231 | 231 | ); |
@@ -236,11 +236,11 @@ discard block |
||
| 236 | 236 | 'type' => 'select2', |
| 237 | 237 | 'label'=> __('Period'), |
| 238 | 238 | ], |
| 239 | - fn () => \App\Models\Period::all()->sortByDesc('id')->pluck('name', 'id')->toArray(), |
|
| 240 | - function ($value) { // if the filter is active |
|
| 239 | + fn() => \App\Models\Period::all()->sortByDesc('id')->pluck('name', 'id')->toArray(), |
|
| 240 | + function($value) { // if the filter is active |
|
| 241 | 241 | CRUD::addClause('where', 'period_id', $value); |
| 242 | 242 | }, |
| 243 | - function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 243 | + function() { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 244 | 244 | $period = \App\Models\Period::get_default_period()->id; |
| 245 | 245 | CRUD::addClause('where', 'period_id', $period); |
| 246 | 246 | $this->crud->getRequest()->request->add(['period_id' => $period]); // to make the filter look active |
@@ -248,13 +248,13 @@ discard block |
||
| 248 | 248 | ); |
| 249 | 249 | |
| 250 | 250 | CRUD::addFilter( |
| 251 | - [ // add a "simple" filter called Draft |
|
| 251 | + [// add a "simple" filter called Draft |
|
| 252 | 252 | 'type' => 'simple', |
| 253 | 253 | 'name' => 'parent', |
| 254 | 254 | 'label'=> __('Hide Children Courses'), |
| 255 | 255 | ], |
| 256 | 256 | false, |
| 257 | - function () { |
|
| 257 | + function() { |
|
| 258 | 258 | CRUD::addClause('parent'); |
| 259 | 259 | } |
| 260 | 260 | ); |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | 'label' => __('Start'), |
| 267 | 267 | ], |
| 268 | 268 | false, |
| 269 | - function ($value) { // if the filter is active, apply these constraints |
|
| 269 | + function($value) { // if the filter is active, apply these constraints |
|
| 270 | 270 | $dates = json_decode($value, null, 512, JSON_THROW_ON_ERROR); |
| 271 | 271 | $this->crud->addClause('where', 'start_date', '>=', $dates->from); |
| 272 | 272 | $this->crud->addClause('where', 'start_date', '<=', $dates->to.' 23:59:59'); |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | 'label' => __('End'), |
| 281 | 281 | ], |
| 282 | 282 | false, |
| 283 | - function ($value) { // if the filter is active, apply these constraints |
|
| 283 | + function($value) { // if the filter is active, apply these constraints |
|
| 284 | 284 | $dates = json_decode($value, null, 512, JSON_THROW_ON_ERROR); |
| 285 | 285 | $this->crud->addClause('where', 'end_date', '>=', $dates->from); |
| 286 | 286 | $this->crud->addClause('where', 'end_date', '<=', $dates->to.' 23:59:59'); |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | 'tab' => __('Course info'), |
| 378 | 378 | ], |
| 379 | 379 | |
| 380 | - [ // repeatable |
|
| 380 | + [// repeatable |
|
| 381 | 381 | 'name' => 'sublevels', |
| 382 | 382 | 'label' => __('Course sublevels'), |
| 383 | 383 | 'type' => 'repeatable', |
@@ -534,7 +534,7 @@ discard block |
||
| 534 | 534 | 'default' => Period::get_enrollments_period()->end, |
| 535 | 535 | ], |
| 536 | 536 | |
| 537 | - [ // repeatable |
|
| 537 | + [// repeatable |
|
| 538 | 538 | 'name' => 'times', |
| 539 | 539 | 'label' => __('Course Schedule'), |
| 540 | 540 | 'type' => 'repeatable', |
@@ -597,14 +597,14 @@ discard block |
||
| 597 | 597 | 'init_rows' => 0, // number of empty rows to be initialized, by default 1 |
| 598 | 598 | ], |
| 599 | 599 | |
| 600 | - [ // view |
|
| 600 | + [// view |
|
| 601 | 601 | 'name' => 'custom-ajax-button', |
| 602 | 602 | 'type' => 'view', |
| 603 | 603 | 'view' => 'courses/schedule-preset-alert', |
| 604 | 604 | 'tab' => __('Schedule'), |
| 605 | 605 | ], |
| 606 | 606 | |
| 607 | - [ // select_from_array |
|
| 607 | + [// select_from_array |
|
| 608 | 608 | 'name' => 'schedulepreset', |
| 609 | 609 | 'label' => __('Schedule Preset'), |
| 610 | 610 | 'type' => 'select_from_array', |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | } |
| 629 | 629 | |
| 630 | 630 | if ($this->crud->getCurrentEntry()->children->count() > 0) { |
| 631 | - CRUD::addField([ // view |
|
| 631 | + CRUD::addField([// view |
|
| 632 | 632 | 'name' => 'custom-ajax-button', |
| 633 | 633 | 'type' => 'view', |
| 634 | 634 | 'view' => 'courses/parent-course-alert', |
@@ -636,7 +636,7 @@ discard block |
||
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | if ($this->crud->getCurrentEntry()->parent_course_id !== null) { |
| 639 | - CRUD::addField([ // view |
|
| 639 | + CRUD::addField([// view |
|
| 640 | 640 | 'name' => 'custom-ajax-button', |
| 641 | 641 | 'type' => 'view', |
| 642 | 642 | 'view' => 'courses/child-course-alert', |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | ], |
| 94 | 94 | false, |
| 95 | 95 | function () { // if the filter is active |
| 96 | - CRUD::addClause('where', 'action', true); |
|
| 97 | - } |
|
| 96 | + CRUD::addClause('where', 'action', true); |
|
| 97 | + } |
|
| 98 | 98 | ); |
| 99 | 99 | |
| 100 | 100 | CRUD::addFilter( |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | CRUD::addClause('where', 'commentable_type', '=', $value); |
| 115 | 115 | }, |
| 116 | 116 | function () { // if the filter is not active |
| 117 | - CRUD::addClause('where', 'commentable_type', '=', Student::class); |
|
| 118 | - $this->crud->getRequest()->request->add(['commentable_type' => Student::class]); // to make the filter look active |
|
| 119 | - } |
|
| 117 | + CRUD::addClause('where', 'commentable_type', '=', Student::class); |
|
| 118 | + $this->crud->getRequest()->request->add(['commentable_type' => Student::class]); // to make the filter look active |
|
| 119 | + } |
|
| 120 | 120 | ); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -86,19 +86,19 @@ discard block |
||
| 86 | 86 | ]); |
| 87 | 87 | |
| 88 | 88 | CRUD::addFilter( |
| 89 | - [ // simple filter |
|
| 89 | + [// simple filter |
|
| 90 | 90 | 'type' => 'simple', |
| 91 | 91 | 'name' => 'action', |
| 92 | 92 | 'label'=> 'Action', |
| 93 | 93 | ], |
| 94 | 94 | false, |
| 95 | - function () { // if the filter is active |
|
| 95 | + function() { // if the filter is active |
|
| 96 | 96 | CRUD::addClause('where', 'action', true); |
| 97 | 97 | } |
| 98 | 98 | ); |
| 99 | 99 | |
| 100 | 100 | CRUD::addFilter( |
| 101 | - [ // dropdown filter |
|
| 101 | + [// dropdown filter |
|
| 102 | 102 | 'name' => 'type', |
| 103 | 103 | 'type' => 'dropdown', |
| 104 | 104 | 'label'=> 'Type', |
@@ -110,10 +110,10 @@ discard block |
||
| 110 | 110 | Result::class => 'Result', |
| 111 | 111 | |
| 112 | 112 | ], |
| 113 | - function ($value) { // if the filter is active |
|
| 113 | + function($value) { // if the filter is active |
|
| 114 | 114 | CRUD::addClause('where', 'commentable_type', '=', $value); |
| 115 | 115 | }, |
| 116 | - function () { // if the filter is not active |
|
| 116 | + function() { // if the filter is not active |
|
| 117 | 117 | CRUD::addClause('where', 'commentable_type', '=', Student::class); |
| 118 | 118 | $this->crud->getRequest()->request->add(['commentable_type' => Student::class]); // to make the filter look active |
| 119 | 119 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | CRUD::addClause('where', 'teacher_id', $value); |
| 79 | 79 | }, |
| 80 | 80 | function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
| 81 | - } |
|
| 81 | + } |
|
| 82 | 82 | ); |
| 83 | 83 | |
| 84 | 84 | CRUD::addFilter( |
@@ -89,10 +89,10 @@ discard block |
||
| 89 | 89 | ], |
| 90 | 90 | false, |
| 91 | 91 | function ($value) { // if the filter is active, apply these constraints |
| 92 | - $dates = json_decode($value, null, 512, JSON_THROW_ON_ERROR); |
|
| 93 | - CRUD::addClause('where', 'date', '>=', $dates->from); |
|
| 94 | - CRUD::addClause('where', 'date', '<=', $dates->to.' 23:59:59'); |
|
| 95 | - } |
|
| 92 | + $dates = json_decode($value, null, 512, JSON_THROW_ON_ERROR); |
|
| 93 | + CRUD::addClause('where', 'date', '>=', $dates->from); |
|
| 94 | + CRUD::addClause('where', 'date', '<=', $dates->to.' 23:59:59'); |
|
| 95 | + } |
|
| 96 | 96 | ); |
| 97 | 97 | } |
| 98 | 98 | |
@@ -68,27 +68,27 @@ discard block |
||
| 68 | 68 | ]); |
| 69 | 69 | |
| 70 | 70 | CRUD::addFilter( |
| 71 | - [ // select2 filter |
|
| 71 | + [// select2 filter |
|
| 72 | 72 | 'name' => 'teacher_id', |
| 73 | 73 | 'type' => 'select2', |
| 74 | 74 | 'label'=> __('Teacher'), |
| 75 | 75 | ], |
| 76 | - fn () => Teacher::all()->pluck('name', 'id')->toArray(), |
|
| 77 | - function ($value) { // if the filter is active |
|
| 76 | + fn() => Teacher::all()->pluck('name', 'id')->toArray(), |
|
| 77 | + function($value) { // if the filter is active |
|
| 78 | 78 | CRUD::addClause('where', 'teacher_id', $value); |
| 79 | 79 | }, |
| 80 | - function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 80 | + function() { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 81 | 81 | } |
| 82 | 82 | ); |
| 83 | 83 | |
| 84 | 84 | CRUD::addFilter( |
| 85 | - [ // daterange filter |
|
| 85 | + [// daterange filter |
|
| 86 | 86 | 'type' => 'date_range', |
| 87 | 87 | 'name' => 'from_to', |
| 88 | 88 | 'label'=> __('Date range'), |
| 89 | 89 | ], |
| 90 | 90 | false, |
| 91 | - function ($value) { // if the filter is active, apply these constraints |
|
| 91 | + function($value) { // if the filter is active, apply these constraints |
|
| 92 | 92 | $dates = json_decode($value, null, 512, JSON_THROW_ON_ERROR); |
| 93 | 93 | CRUD::addClause('where', 'date', '>=', $dates->from); |
| 94 | 94 | CRUD::addClause('where', 'date', '<=', $dates->to.' 23:59:59'); |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | 'model' => LeaveType::class, |
| 122 | 122 | ], |
| 123 | 123 | |
| 124 | - [ // date_range |
|
| 124 | + [// date_range |
|
| 125 | 125 | 'name' => ['start_date', 'end_date'], // db columns for start_date & end_date |
| 126 | 126 | 'label' => 'Event Date Range', |
| 127 | 127 | 'type' => 'date_range', |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | 'model' => LeaveType::class, |
| 166 | 166 | ], |
| 167 | 167 | |
| 168 | - [ // datepicker |
|
| 168 | + [// datepicker |
|
| 169 | 169 | 'name' => 'date', |
| 170 | 170 | 'label' => 'Event Date', |
| 171 | 171 | 'type' => 'date', |
@@ -119,15 +119,15 @@ discard block |
||
| 119 | 119 | ], |
| 120 | 120 | false, |
| 121 | 121 | function ($value) { // if the filter is active, apply these constraints |
| 122 | - $dates = json_decode($value, null, 512, JSON_THROW_ON_ERROR); |
|
| 123 | - |
|
| 124 | - if ($dates->from) { |
|
| 125 | - CRUD::addClause('where', 'start', '>=', $dates->from); |
|
| 126 | - } |
|
| 127 | - if ($dates->to) { |
|
| 128 | - CRUD::addClause('where', 'start', '<=', $dates->to.' 23:59:59'); |
|
| 129 | - } |
|
| 130 | - } |
|
| 122 | + $dates = json_decode($value, null, 512, JSON_THROW_ON_ERROR); |
|
| 123 | + |
|
| 124 | + if ($dates->from) { |
|
| 125 | + CRUD::addClause('where', 'start', '>=', $dates->from); |
|
| 126 | + } |
|
| 127 | + if ($dates->to) { |
|
| 128 | + CRUD::addClause('where', 'start', '<=', $dates->to.' 23:59:59'); |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | 131 | ); |
| 132 | 132 | |
| 133 | 133 | CRUD::addFilter( |
@@ -138,10 +138,10 @@ discard block |
||
| 138 | 138 | ], |
| 139 | 139 | false, |
| 140 | 140 | function ($value) { // if the filter is active, apply these constraints |
| 141 | - $this->crud->query->where('course_id', null); |
|
| 142 | - }, |
|
| 141 | + $this->crud->query->where('course_id', null); |
|
| 142 | + }, |
|
| 143 | 143 | function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
| 144 | - } |
|
| 144 | + } |
|
| 145 | 145 | ); |
| 146 | 146 | |
| 147 | 147 | CRUD::addFilter( |
@@ -152,8 +152,8 @@ discard block |
||
| 152 | 152 | ], |
| 153 | 153 | false, |
| 154 | 154 | function ($value) { // if the filter is active, apply these constraints |
| 155 | - CRUD::addClause('unassigned'); |
|
| 156 | - } |
|
| 155 | + CRUD::addClause('unassigned'); |
|
| 156 | + } |
|
| 157 | 157 | ); |
| 158 | 158 | |
| 159 | 159 | CRUD::addFilter( |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | CRUD::addClause('where', 'teacher_id', $value); |
| 168 | 168 | }, |
| 169 | 169 | function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
| 170 | - } |
|
| 170 | + } |
|
| 171 | 171 | ); |
| 172 | 172 | } |
| 173 | 173 | |
@@ -112,13 +112,13 @@ discard block |
||
| 112 | 112 | ]); |
| 113 | 113 | |
| 114 | 114 | CRUD::addFilter( |
| 115 | - [ // daterange filter |
|
| 115 | + [// daterange filter |
|
| 116 | 116 | 'type' => 'date_range', |
| 117 | 117 | 'name' => 'from_to', |
| 118 | 118 | 'label'=> __('Date range'), |
| 119 | 119 | ], |
| 120 | 120 | false, |
| 121 | - function ($value) { // if the filter is active, apply these constraints |
|
| 121 | + function($value) { // if the filter is active, apply these constraints |
|
| 122 | 122 | $dates = json_decode($value, null, 512, JSON_THROW_ON_ERROR); |
| 123 | 123 | |
| 124 | 124 | if ($dates->from) { |
@@ -137,10 +137,10 @@ discard block |
||
| 137 | 137 | 'label'=> __('Events with no course'), |
| 138 | 138 | ], |
| 139 | 139 | false, |
| 140 | - function ($value) { // if the filter is active, apply these constraints |
|
| 140 | + function($value) { // if the filter is active, apply these constraints |
|
| 141 | 141 | $this->crud->query->where('course_id', null); |
| 142 | 142 | }, |
| 143 | - function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 143 | + function() { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 144 | 144 | } |
| 145 | 145 | ); |
| 146 | 146 | |
@@ -151,22 +151,22 @@ discard block |
||
| 151 | 151 | 'label'=> __('Events with no teacher'), |
| 152 | 152 | ], |
| 153 | 153 | false, |
| 154 | - function ($value) { // if the filter is active, apply these constraints |
|
| 154 | + function($value) { // if the filter is active, apply these constraints |
|
| 155 | 155 | CRUD::addClause('unassigned'); |
| 156 | 156 | } |
| 157 | 157 | ); |
| 158 | 158 | |
| 159 | 159 | CRUD::addFilter( |
| 160 | - [ // select2 filter |
|
| 160 | + [// select2 filter |
|
| 161 | 161 | 'name' => 'teacher_id', |
| 162 | 162 | 'type' => 'select2', |
| 163 | 163 | 'label'=> __('Teacher'), |
| 164 | 164 | ], |
| 165 | - fn () => Teacher::all()->pluck('name', 'id')->toArray(), |
|
| 166 | - function ($value) { // if the filter is active |
|
| 165 | + fn() => Teacher::all()->pluck('name', 'id')->toArray(), |
|
| 166 | + function($value) { // if the filter is active |
|
| 167 | 167 | CRUD::addClause('where', 'teacher_id', $value); |
| 168 | 168 | }, |
| 169 | - function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 169 | + function() { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 170 | 170 | } |
| 171 | 171 | ); |
| 172 | 172 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | $q->where('firstname', 'like', '%'.$searchTerm.'%') |
| 59 | 59 | ->orWhere('lastname', 'like', '%'.$searchTerm.'%') |
| 60 | 60 | ->orWhere('email', 'like', '%'.$searchTerm.'%') |
| 61 | - ->orWhere('idnumber', 'like', '%'.$searchTerm.'%'); |
|
| 61 | + ->orWhere('idnumber', 'like', '%'.$searchTerm.'%'); |
|
| 62 | 62 | }); |
| 63 | 63 | }); |
| 64 | 64 | }, |
@@ -95,8 +95,8 @@ discard block |
||
| 95 | 95 | ], |
| 96 | 96 | false, |
| 97 | 97 | function () { |
| 98 | - CRUD::addClause('noResult'); |
|
| 99 | - } |
|
| 98 | + CRUD::addClause('noResult'); |
|
| 99 | + } |
|
| 100 | 100 | ); |
| 101 | 101 | |
| 102 | 102 | CRUD::addFilter( |
@@ -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.'%') |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | 'label'=> __('No Result'), |
| 95 | 95 | ], |
| 96 | 96 | false, |
| 97 | - function () { |
|
| 97 | + function() { |
|
| 98 | 98 | CRUD::addClause('noResult'); |
| 99 | 99 | } |
| 100 | 100 | ); |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | 'label'=> __('Hide Parents'), |
| 107 | 107 | ], |
| 108 | 108 | false, |
| 109 | - function () { |
|
| 109 | + function() { |
|
| 110 | 110 | CRUD::addClause('real'); |
| 111 | 111 | } |
| 112 | 112 | ); |
@@ -115,16 +115,16 @@ discard block |
||
| 115 | 115 | 'name' => 'period_id', |
| 116 | 116 | 'type' => 'select2', |
| 117 | 117 | 'label'=> __('Period'), |
| 118 | - ], fn () => Period::all()->pluck('name', 'id')->toArray(), function ($value) { // if the filter is active |
|
| 118 | + ], fn() => Period::all()->pluck('name', 'id')->toArray(), function($value) { // if the filter is active |
|
| 119 | 119 | CRUD::addClause('period', $value); |
| 120 | 120 | }); |
| 121 | 121 | |
| 122 | - CRUD::addFilter([ // select2_multiple filter |
|
| 122 | + CRUD::addFilter([// select2_multiple filter |
|
| 123 | 123 | 'name' => 'result', |
| 124 | 124 | 'type' => 'select2', |
| 125 | 125 | 'label'=> __('Result'), |
| 126 | - ], fn () => ResultType::all()->pluck('name', 'id')->toArray(), function ($value) { // if the filter is active |
|
| 127 | - $this->crud->query = $this->crud->query->whereHas('result', function ($query) use ($value) { |
|
| 126 | + ], fn() => ResultType::all()->pluck('name', 'id')->toArray(), function($value) { // if the filter is active |
|
| 127 | + $this->crud->query = $this->crud->query->whereHas('result', function($query) use ($value) { |
|
| 128 | 128 | $query->where('result_type_id', $value); |
| 129 | 129 | }); |
| 130 | 130 | }); |