@@ -54,7 +54,8 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | public function search() |
| 56 | 56 | { |
| 57 | - return QueryBuilder::for(Course::class)->where('campus_id', 1) |
|
| 57 | + return QueryBuilder::for(Course::class) { |
|
| 58 | + ->where('campus_id', 1) |
|
| 58 | 59 | ->with('room')->withCount('events')->withCount('children')->withCount('enrollments') |
| 59 | 60 | ->allowedFilters([ |
| 60 | 61 | 'name', |
@@ -63,5 +64,6 @@ discard block |
||
| 63 | 64 | AllowedFilter::custom('searchable_levels', new FiltersSearchableLevels()), |
| 64 | 65 | 'teacher_id', ]) |
| 65 | 66 | ->get(); |
| 67 | + } |
|
| 66 | 68 | } |
| 67 | 69 | } |
@@ -92,10 +92,10 @@ discard block |
||
| 92 | 92 | 'name' => 'action', |
| 93 | 93 | 'label'=> 'Action', |
| 94 | 94 | ], |
| 95 | - false, |
|
| 96 | - function () { // if the filter is active |
|
| 97 | - CRUD::addClause('where', 'action', true); |
|
| 98 | - }); |
|
| 95 | + false, |
|
| 96 | + function () { // if the filter is active |
|
| 97 | + CRUD::addClause('where', 'action', true); |
|
| 98 | + }); |
|
| 99 | 99 | |
| 100 | 100 | CRUD::addFilter([ // dropdown filter |
| 101 | 101 | 'name' => 'type', |
@@ -109,10 +109,10 @@ discard block |
||
| 109 | 109 | ], function ($value) { // if the filter is active |
| 110 | 110 | CRUD::addClause('where', 'commentable_type', '=', $value); |
| 111 | 111 | }, |
| 112 | - function () { // if the filter is not active |
|
| 113 | - CRUD::addClause('where', 'commentable_type', '=', Student::class); |
|
| 114 | - $this->crud->getRequest()->request->add(['commentable_type' => Student::class]); // to make the filter look active |
|
| 115 | - }); |
|
| 112 | + function () { // if the filter is not active |
|
| 113 | + CRUD::addClause('where', 'commentable_type', '=', Student::class); |
|
| 114 | + $this->crud->getRequest()->request->add(['commentable_type' => Student::class]); // to make the filter look active |
|
| 115 | + }); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | public function setupUpdateOperation() |
@@ -181,8 +181,8 @@ discard block |
||
| 181 | 181 | }, function ($value) { // if the filter is active |
| 182 | 182 | CRUD::addClause('where', 'rhythm_id', $value); |
| 183 | 183 | }, |
| 184 | - function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 185 | - }); |
|
| 184 | + function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 185 | + }); |
|
| 186 | 186 | |
| 187 | 187 | CRUD::addFilter([ // select2 filter |
| 188 | 188 | 'name' => 'teacher_id', |
@@ -193,8 +193,8 @@ discard block |
||
| 193 | 193 | }, function ($value) { // if the filter is active |
| 194 | 194 | CRUD::addClause('where', 'teacher_id', $value); |
| 195 | 195 | }, |
| 196 | - function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 197 | - }); |
|
| 196 | + function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 197 | + }); |
|
| 198 | 198 | |
| 199 | 199 | CRUD::addFilter([ // select2 filter |
| 200 | 200 | 'name' => 'level_id', |
@@ -205,8 +205,8 @@ discard block |
||
| 205 | 205 | }, function ($value) { // if the filter is active |
| 206 | 206 | CRUD::addClause('where', 'level_id', $value); |
| 207 | 207 | }, |
| 208 | - function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 209 | - }); |
|
| 208 | + function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 209 | + }); |
|
| 210 | 210 | |
| 211 | 211 | CRUD::addFilter([ // select2 filter |
| 212 | 212 | 'name' => 'period_id', |
@@ -217,11 +217,11 @@ discard block |
||
| 217 | 217 | }, function ($value) { // if the filter is active |
| 218 | 218 | CRUD::addClause('where', 'period_id', $value); |
| 219 | 219 | }, |
| 220 | - function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 221 | - $period = Period::get_default_period()->id; |
|
| 222 | - CRUD::addClause('where', 'period_id', $period); |
|
| 223 | - $this->crud->getRequest()->request->add(['period_id' => $period]); // to make the filter look active |
|
| 224 | - }); |
|
| 220 | + function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 221 | + $period = Period::get_default_period()->id; |
|
| 222 | + CRUD::addClause('where', 'period_id', $period); |
|
| 223 | + $this->crud->getRequest()->request->add(['period_id' => $period]); // to make the filter look active |
|
| 224 | + }); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | protected function setupCreateOperation() |
@@ -95,8 +95,8 @@ discard block |
||
| 95 | 95 | }, function ($value) { // if the filter is active |
| 96 | 96 | CRUD::addClause('where', 'rhythm_id', $value); |
| 97 | 97 | }, |
| 98 | - function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 99 | - }); |
|
| 98 | + function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 99 | + }); |
|
| 100 | 100 | |
| 101 | 101 | CRUD::addFilter([ // select2 filter |
| 102 | 102 | 'name' => 'teacher_id', |
@@ -107,8 +107,8 @@ discard block |
||
| 107 | 107 | }, function ($value) { // if the filter is active |
| 108 | 108 | CRUD::addClause('where', 'teacher_id', $value); |
| 109 | 109 | }, |
| 110 | - function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 111 | - }); |
|
| 110 | + function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 111 | + }); |
|
| 112 | 112 | |
| 113 | 113 | CRUD::addFilter([ // select2 filter |
| 114 | 114 | 'name' => 'level_id', |
@@ -119,8 +119,8 @@ discard block |
||
| 119 | 119 | }, function ($value) { // if the filter is active |
| 120 | 120 | CRUD::addClause('where', 'level_id', $value); |
| 121 | 121 | }, |
| 122 | - function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 123 | - }); |
|
| 122 | + function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 123 | + }); |
|
| 124 | 124 | |
| 125 | 125 | CRUD::addFilter([ // select2 filter |
| 126 | 126 | 'name' => 'period_id', |
@@ -131,11 +131,11 @@ discard block |
||
| 131 | 131 | }, function ($value) { // if the filter is active |
| 132 | 132 | CRUD::addClause('where', 'period_id', $value); |
| 133 | 133 | }, |
| 134 | - function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 135 | - $period = Period::get_default_period()->id; |
|
| 136 | - CRUD::addClause('where', 'period_id', $period); |
|
| 137 | - $this->crud->getRequest()->request->add(['period_id' => $period]); // to make the filter look active |
|
| 138 | - }); |
|
| 134 | + function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 135 | + $period = Period::get_default_period()->id; |
|
| 136 | + CRUD::addClause('where', 'period_id', $period); |
|
| 137 | + $this->crud->getRequest()->request->add(['period_id' => $period]); // to make the filter look active |
|
| 138 | + }); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | protected function setupCreateOperation() |