| @@ -29,7 +29,7 @@ discard block | ||
| 29 | 29 | parent::boot(); | 
| 30 | 30 | |
| 31 | 31 | // when deleting a student, also delete any enrollments, grades and attendance related to this student | 
| 32 | -        static::deleting(function (self $student) { | |
| 32 | +        static::deleting(function(self $student) { | |
| 33 | 33 |              Attendance::where('student_id', $student->id)->delete(); | 
| 34 | 34 |              Enrollment::where('student_id', $student->id)->delete(); | 
| 35 | 35 | }); | 
| @@ -66,8 +66,8 @@ discard block | ||
| 66 | 66 | |
| 67 | 67 | return $this->hasMany(Attendance::class) | 
| 68 | 68 |          ->where('attendance_type_id', 4) // absence | 
| 69 | -        ->whereHas('event', function ($q) use ($period) { | |
| 70 | -            return $q->whereHas('course', function ($c) use ($period) { | |
| 69 | +        ->whereHas('event', function($q) use ($period) { | |
| 70 | +            return $q->whereHas('course', function($c) use ($period) { | |
| 71 | 71 |                  return $c->where('period_id', $period->id); | 
| 72 | 72 | }); | 
| 73 | 73 | }); | 
| @@ -80,8 +80,8 @@ discard block | ||
| 80 | 80 | } | 
| 81 | 81 | |
| 82 | 82 | return $this->hasMany(Attendance::class) | 
| 83 | -        ->whereHas('event', function ($q) use ($period) { | |
| 84 | -            return $q->whereHas('course', function ($c) use ($period) { | |
| 83 | +        ->whereHas('event', function($q) use ($period) { | |
| 84 | +            return $q->whereHas('course', function($c) use ($period) { | |
| 85 | 85 |                  return $c->where('period_id', $period->id); | 
| 86 | 86 | }); | 
| 87 | 87 | }); | 
| @@ -173,7 +173,7 @@ discard block | ||
| 173 | 173 | public function getIsEnrolledAttribute() | 
| 174 | 174 |      { | 
| 175 | 175 | // if the student is currently enrolled | 
| 176 | -        if ($this->enrollments()->whereHas('course', function ($q) { | |
| 176 | +        if ($this->enrollments()->whereHas('course', function($q) { | |
| 177 | 177 |              return $q->where('period_id', Period::get_default_period()->id); | 
| 178 | 178 |          })->count() > 0) { | 
| 179 | 179 | return 1; | 
| @@ -29,7 +29,7 @@ discard block | ||
| 29 | 29 | * a user is allowed to view the course attendance sheet if they are the teacher for this course, | 
| 30 | 30 | * or if they have explicit permission to view all course attendance sheets | 
| 31 | 31 | */ | 
| 32 | -        Gate::define('view-course-attendance', function ($user, $course) { | |
| 32 | +        Gate::define('view-course-attendance', function($user, $course) { | |
| 33 | 33 |              return $user->teacher_id == $course->teacher_id || $user->can('attendance.view'); | 
| 34 | 34 | }); | 
| 35 | 35 | |
| @@ -38,7 +38,7 @@ discard block | ||
| 38 | 38 | * if they are the teacher for this course, | 
| 39 | 39 | * or if they have explicit permission to view all event attendance sheets | 
| 40 | 40 | */ | 
| 41 | -        Gate::define('view-event-attendance', function ($user, $event) { | |
| 41 | +        Gate::define('view-event-attendance', function($user, $event) { | |
| 42 | 42 |              return ($event->teacher_id == $user->teacher_id) || ($event->course->teacher_id == $user->teacher_id) || $user->can('attendance.view'); | 
| 43 | 43 | }); | 
| 44 | 44 | |
| @@ -47,7 +47,7 @@ discard block | ||
| 47 | 47 | * if they are the teacher for the course, | 
| 48 | 48 | * or if they have explicit permission to edit any attendance sheets | 
| 49 | 49 | */ | 
| 50 | -        Gate::define('edit-attendance', function ($user, $event) { | |
| 50 | +        Gate::define('edit-attendance', function($user, $event) { | |
| 51 | 51 |              return ($event->teacher_id == $user->teacher_id) || ($event->course->teacher_id == $user->teacher_id) || $user->can('attendance.edit'); | 
| 52 | 52 | }); | 
| 53 | 53 | |
| @@ -55,7 +55,7 @@ discard block | ||
| 55 | 55 | * teachers are allowed to view their own calendar, | 
| 56 | 56 | * and users with explicit permission can view all calendars | 
| 57 | 57 | */ | 
| 58 | -        Gate::define('view-teacher-calendar', function ($user, $teacher) { | |
| 58 | +        Gate::define('view-teacher-calendar', function($user, $teacher) { | |
| 59 | 59 |              return ($user->teacher_id == $teacher->id) || $user->can('calendars.view'); | 
| 60 | 60 | }); | 
| 61 | 61 | |
| @@ -63,7 +63,7 @@ discard block | ||
| 63 | 63 | * teachers are allowed to view their own courses, | 
| 64 | 64 | * and users with explicit permission can view all courses | 
| 65 | 65 | */ | 
| 66 | -        Gate::define('view-course', function ($user, $course) { | |
| 66 | +        Gate::define('view-course', function($user, $course) { | |
| 67 | 67 |              return ($user->teacher_id == $course->teacher_id) || $user->can('courses.view'); | 
| 68 | 68 | }); | 
| 69 | 69 | |
| @@ -72,7 +72,7 @@ discard block | ||
| 72 | 72 | * if they are a teacher | 
| 73 | 73 | * of if they have explicit permission to view any result | 
| 74 | 74 | */ | 
| 75 | -        Gate::define('view-enrollment', function ($user, $enrollment) { | |
| 75 | +        Gate::define('view-enrollment', function($user, $enrollment) { | |
| 76 | 76 |              return ($user->student_id == $enrollment->student_id) || $user->isTeacher() || $user->can('evaluation.view'); | 
| 77 | 77 | }); | 
| 78 | 78 | |
| @@ -80,7 +80,7 @@ discard block | ||
| 80 | 80 | * if the user is the teacher of the course | 
| 81 | 81 | * of if they have explicit permission to enroll students | 
| 82 | 82 | */ | 
| 83 | -        Gate::define('enroll-in-course', function ($user, $course) { | |
| 83 | +        Gate::define('enroll-in-course', function($user, $course) { | |
| 84 | 84 |              return $course->teacher_id == $user->teacher_id || $user->can('enrollments.edit'); | 
| 85 | 85 | }); | 
| 86 | 86 | |
| @@ -88,7 +88,7 @@ discard block | ||
| 88 | 88 | * if the user is a teacher | 
| 89 | 89 | * of if they have explicit permission to enroll students | 
| 90 | 90 | */ | 
| 91 | -        Gate::define('enroll-students', function ($user) { | |
| 91 | +        Gate::define('enroll-students', function($user) { | |
| 92 | 92 |              return $user->isTeacher() || $user->can('enrollments.edit'); | 
| 93 | 93 | }); | 
| 94 | 94 | |
| @@ -96,7 +96,7 @@ discard block | ||
| 96 | 96 | * teachers are allowed to view their own hours, | 
| 97 | 97 | * and users with explicit permission can view all hours | 
| 98 | 98 | */ | 
| 99 | -        Gate::define('view-teacher-hours', function ($user, $teacher) { | |
| 99 | +        Gate::define('view-teacher-hours', function($user, $teacher) { | |
| 100 | 100 |              return ($user->teacher_id == $teacher->id) || $user->can('hr.view'); | 
| 101 | 101 | }); | 
| 102 | 102 | |
| @@ -104,7 +104,7 @@ discard block | ||
| 104 | 104 | * teachers are allowed to edit results for their own students | 
| 105 | 105 | * as well as users with explicit permission to edit any result | 
| 106 | 106 | */ | 
| 107 | -        Gate::define('edit-result', function ($user, $enrollment) { | |
| 107 | +        Gate::define('edit-result', function($user, $enrollment) { | |
| 108 | 108 |              return ($user->teacher_id == $enrollment->course->teacher_id) || $user->can('evaluation.edit'); | 
| 109 | 109 | }); | 
| 110 | 110 | } | 
| @@ -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() | 
| @@ -87,17 +87,17 @@ discard block | ||
| 87 | 87 | ], | 
| 88 | 88 | ]); | 
| 89 | 89 | |
| 90 | - CRUD::addFilter([ // simple filter | |
| 90 | + CRUD::addFilter([// simple filter | |
| 91 | 91 | 'type' => 'simple', | 
| 92 | 92 | 'name' => 'action', | 
| 93 | 93 | 'label'=> 'Action', | 
| 94 | 94 | ], | 
| 95 | 95 | false, | 
| 96 | -              function () { // if the filter is active | |
| 96 | +              function() { // if the filter is active | |
| 97 | 97 |                    CRUD::addClause('where', 'action', true); | 
| 98 | 98 | }); | 
| 99 | 99 | |
| 100 | - CRUD::addFilter([ // dropdown filter | |
| 100 | + CRUD::addFilter([// dropdown filter | |
| 101 | 101 | 'name' => 'type', | 
| 102 | 102 | 'type' => 'dropdown', | 
| 103 | 103 | 'label'=> 'Type', | 
| @@ -106,10 +106,10 @@ discard block | ||
| 106 | 106 | Enrollment::class => 'Enrollments', | 
| 107 | 107 | Result::class => 'Result', | 
| 108 | 108 | |
| 109 | -        ], function ($value) { // if the filter is active | |
| 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 | |
| 112 | +              function() { // if the filter is not active | |
| 113 | 113 |                    CRUD::addClause('where', 'commentable_type', '=', Student::class); | 
| 114 | 114 | $this->crud->getRequest()->request->add(['commentable_type' => Student::class]); // to make the filter look active | 
| 115 | 115 | }); | 
| @@ -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() | 
| @@ -57,11 +57,11 @@ discard block | ||
| 57 | 57 | |
| 58 | 58 | $permissions = backpack_user()->getAllPermissions(); | 
| 59 | 59 | |
| 60 | -        if (! $permissions->contains('name', 'courses.edit')) { | |
| 60 | +        if (!$permissions->contains('name', 'courses.edit')) { | |
| 61 | 61 |              CRUD::denyAccess('update'); | 
| 62 | 62 | } | 
| 63 | 63 | |
| 64 | -        if (! $permissions->contains('name', 'courses.edit')) { | |
| 64 | +        if (!$permissions->contains('name', 'courses.edit')) { | |
| 65 | 65 |              CRUD::denyAccess('create'); | 
| 66 | 66 | } | 
| 67 | 67 | |
| @@ -75,7 +75,7 @@ discard block | ||
| 75 | 75 | |
| 76 | 76 |          CRUD::addButtonFromView('line', 'children_badge', 'children_badge', 'beginning'); | 
| 77 | 77 | |
| 78 | -        if (! $permissions->contains('name', 'courses.delete')) { | |
| 78 | +        if (!$permissions->contains('name', 'courses.delete')) { | |
| 79 | 79 |              CRUD::denyAccess('delete'); | 
| 80 | 80 | } | 
| 81 | 81 | |
| @@ -172,52 +172,52 @@ discard block | ||
| 172 | 172 | |
| 173 | 173 | ]); | 
| 174 | 174 | |
| 175 | - CRUD::addFilter([ // select2 filter | |
| 175 | + CRUD::addFilter([// select2 filter | |
| 176 | 176 | 'name' => 'rhythm_id', | 
| 177 | 177 | 'type' => 'select2', | 
| 178 | 178 |              'label'=> __('Rhythm'), | 
| 179 | -        ], function () { | |
| 179 | +        ], function() { | |
| 180 | 180 |              return Rhythm::all()->pluck('name', 'id')->toArray(); | 
| 181 | -        }, function ($value) { // if the filter is active | |
| 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) | |
| 184 | +          function() { // if the filter is NOT active (the GET parameter "checkbox" does not exit) | |
| 185 | 185 | }); | 
| 186 | 186 | |
| 187 | - CRUD::addFilter([ // select2 filter | |
| 187 | + CRUD::addFilter([// select2 filter | |
| 188 | 188 | 'name' => 'teacher_id', | 
| 189 | 189 | 'type' => 'select2', | 
| 190 | 190 |              'label'=> __('Teacher'), | 
| 191 | -        ], function () { | |
| 191 | +        ], function() { | |
| 192 | 192 |              return Teacher::all()->pluck('name', 'id')->toArray(); | 
| 193 | -        }, function ($value) { // if the filter is active | |
| 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) | |
| 196 | +          function() { // if the filter is NOT active (the GET parameter "checkbox" does not exit) | |
| 197 | 197 | }); | 
| 198 | 198 | |
| 199 | - CRUD::addFilter([ // select2 filter | |
| 199 | + CRUD::addFilter([// select2 filter | |
| 200 | 200 | 'name' => 'level_id', | 
| 201 | 201 | 'type' => 'select2', | 
| 202 | 202 |              'label'=> __('Level'), | 
| 203 | -        ], function () { | |
| 203 | +        ], function() { | |
| 204 | 204 |              return Level::all()->pluck('name', 'id')->toArray(); | 
| 205 | -        }, function ($value) { // if the filter is active | |
| 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) | |
| 208 | +          function() { // if the filter is NOT active (the GET parameter "checkbox" does not exit) | |
| 209 | 209 | }); | 
| 210 | 210 | |
| 211 | - CRUD::addFilter([ // select2 filter | |
| 211 | + CRUD::addFilter([// select2 filter | |
| 212 | 212 | 'name' => 'period_id', | 
| 213 | 213 | 'type' => 'select2', | 
| 214 | 214 |              'label'=> __('Period'), | 
| 215 | -        ], function () { | |
| 215 | +        ], function() { | |
| 216 | 216 |              return Period::all()->sortByDesc('id')->pluck('name', 'id')->toArray(); | 
| 217 | -        }, function ($value) { // if the filter is active | |
| 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) | |
| 220 | +          function() { // if the filter is NOT active (the GET parameter "checkbox" does not exit) | |
| 221 | 221 | $period = Period::get_default_period()->id; | 
| 222 | 222 |                CRUD::addClause('where', 'period_id', $period); | 
| 223 | 223 | $this->crud->getRequest()->request->add(['period_id' => $period]); // to make the filter look active | 
| @@ -35,7 +35,7 @@ discard block | ||
| 35 | 35 | protected function setupListOperation() | 
| 36 | 36 |      { | 
| 37 | 37 | CRUD::setColumns([ | 
| 38 | - [ // skill type | |
| 38 | + [// skill type | |
| 39 | 39 | 'label' => 'Type', // Table column heading | 
| 40 | 40 | 'type' => 'select', | 
| 41 | 41 | 'name' => 'skill_type', // the method that defines the relationship in your Model | 
| @@ -48,7 +48,7 @@ discard block | ||
| 48 | 48 | 'type' => 'text', | 
| 49 | 49 | 'name' => 'name', | 
| 50 | 50 | ], | 
| 51 | - [ // skill level | |
| 51 | + [// skill level | |
| 52 | 52 | 'label' => 'Level', // Table column heading | 
| 53 | 53 | 'type' => 'select', | 
| 54 | 54 | 'name' => 'level', // the method that defines the relationship in your Model | 
| @@ -60,23 +60,23 @@ discard block | ||
| 60 | 60 | |
| 61 | 61 | CRUD::enableBulkActions(); | 
| 62 | 62 | |
| 63 | - CRUD::addFilter([ // select2 filter | |
| 63 | + CRUD::addFilter([// select2 filter | |
| 64 | 64 | 'name' => 'level_id', | 
| 65 | 65 | 'type' => 'select2', | 
| 66 | 66 | 'label'=> 'Level', | 
| 67 | -        ], function () { | |
| 67 | +        ], function() { | |
| 68 | 68 |              return Level::all()->pluck('name', 'id')->toArray(); | 
| 69 | -        }, function ($value) { // if the filter is active | |
| 69 | +        }, function($value) { // if the filter is active | |
| 70 | 70 |              CRUD::addClause('where', 'level_id', $value); | 
| 71 | 71 | }); | 
| 72 | 72 | |
| 73 | - CRUD::addFilter([ // select2 filter | |
| 73 | + CRUD::addFilter([// select2 filter | |
| 74 | 74 | 'name' => 'skill_type_id', | 
| 75 | 75 | 'type' => 'select2', | 
| 76 | 76 | 'label'=> 'Type', | 
| 77 | -        ], function () { | |
| 77 | +        ], function() { | |
| 78 | 78 |              return SkillType::all()->pluck('name', 'id')->toArray(); | 
| 79 | -        }, function ($value) { // if the filter is active | |
| 79 | +        }, function($value) { // if the filter is active | |
| 80 | 80 |              CRUD::addClause('where', 'skill_type_id', $value); | 
| 81 | 81 | }); | 
| 82 | 82 | } | 
| @@ -85,7 +85,7 @@ discard block | ||
| 85 | 85 |      { | 
| 86 | 86 | CRUD::setValidation(StoreRequest::class); | 
| 87 | 87 | CRUD::addFields([ | 
| 88 | - [ // skill type | |
| 88 | + [// skill type | |
| 89 | 89 | 'label' => 'Type', // Table column heading | 
| 90 | 90 | 'type' => 'select', | 
| 91 | 91 | 'name' => 'skill_type_id', // the db column for the foreign key | 
| @@ -98,7 +98,7 @@ discard block | ||
| 98 | 98 | 'type' => 'text', | 
| 99 | 99 | 'name' => 'name', | 
| 100 | 100 | ], | 
| 101 | - [ // skill level | |
| 101 | + [// skill level | |
| 102 | 102 | 'label' => 'Level', // Table column heading | 
| 103 | 103 | 'type' => 'select', | 
| 104 | 104 | 'name' => 'level_id', // the db column for the foreign key | 
| @@ -62,12 +62,12 @@ discard block | ||
| 62 | 62 | 'attribute' => 'lastname', // foreign key attribute that is shown to user | 
| 63 | 63 | 'model' => 'App\Models\User', // foreign key model | 
| 64 | 64 | 'orderable' => true, | 
| 65 | -                'orderLogic' => function ($query, $column, $columnDirection) { | |
| 65 | +                'orderLogic' => function($query, $column, $columnDirection) { | |
| 66 | 66 |                      return $query->leftJoin('users', 'users.id', '=', 'students.user_id') | 
| 67 | 67 |                          ->orderBy('users.lastname', $columnDirection)->select('students.*'); | 
| 68 | 68 | }, | 
| 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('lastname', 'like', '%'.$searchTerm.'%'); | 
| 72 | 72 | }); | 
| 73 | 73 | }, | 
| @@ -82,12 +82,12 @@ discard block | ||
| 82 | 82 | 'attribute' => 'firstname', // foreign key attribute that is shown to user | 
| 83 | 83 | 'model' => 'App\Models\User', // foreign key model | 
| 84 | 84 | 'orderable' => true, | 
| 85 | -                'orderLogic' => function ($query, $column, $columnDirection) { | |
| 85 | +                'orderLogic' => function($query, $column, $columnDirection) { | |
| 86 | 86 |                      return $query->leftJoin('users', 'users.id', '=', 'students.user_id') | 
| 87 | 87 |                          ->orderBy('users.firstname', $columnDirection)->select('students.*'); | 
| 88 | 88 | }, | 
| 89 | -                'searchLogic' => function ($query, $column, $searchTerm) { | |
| 90 | -                    $query->orWhereHas('user', function ($q) use ($searchTerm) { | |
| 89 | +                'searchLogic' => function($query, $column, $searchTerm) { | |
| 90 | +                    $query->orWhereHas('user', function($q) use ($searchTerm) { | |
| 91 | 91 |                          $q->where('firstname', 'like', '%'.$searchTerm.'%'); | 
| 92 | 92 | }); | 
| 93 | 93 | }, | 
| @@ -102,12 +102,12 @@ discard block | ||
| 102 | 102 | 'attribute' => 'email', // foreign key attribute that is shown to user | 
| 103 | 103 | 'model' => 'App\Models\User', // foreign key model | 
| 104 | 104 | 'orderable' => true, | 
| 105 | -                'orderLogic' => function ($query, $column, $columnDirection) { | |
| 105 | +                'orderLogic' => function($query, $column, $columnDirection) { | |
| 106 | 106 |                      return $query->leftJoin('users', 'users.id', '=', 'students.user_id') | 
| 107 | 107 |                          ->orderBy('users.email', $columnDirection)->select('students.*'); | 
| 108 | 108 | }, | 
| 109 | -                'searchLogic' => function ($query, $column, $searchTerm) { | |
| 110 | -                    $query->orWhereHas('user', function ($q) use ($searchTerm) { | |
| 109 | +                'searchLogic' => function($query, $column, $searchTerm) { | |
| 110 | +                    $query->orWhereHas('user', function($q) use ($searchTerm) { | |
| 111 | 111 |                          $q->where('email', 'like', '%'.$searchTerm.'%'); | 
| 112 | 112 | }); | 
| 113 | 113 | }, | 
| @@ -125,32 +125,32 @@ discard block | ||
| 125 | 125 | |
| 126 | 126 | ]); | 
| 127 | 127 | |
| 128 | - CRUD::addFilter([ // select2 filter | |
| 128 | + CRUD::addFilter([// select2 filter | |
| 129 | 129 | 'name' => 'enrolled', | 
| 130 | 130 | 'type' => 'select2', | 
| 131 | 131 |              'label'=> __('Is Enrolled in'), | 
| 132 | -        ], function () { | |
| 132 | +        ], function() { | |
| 133 | 133 |              return Period::all()->pluck('name', 'id')->toArray(); | 
| 134 | -        }, function ($value) { // if the filter is active | |
| 135 | -            $this->crud->query = $this->crud->query->whereHas('enrollments', function ($query) use ($value) { | |
| 136 | -                return $query->whereHas('course', function ($q) use ($value) { | |
| 134 | +        }, function($value) { // if the filter is active | |
| 135 | +            $this->crud->query = $this->crud->query->whereHas('enrollments', function($query) use ($value) { | |
| 136 | +                return $query->whereHas('course', function($q) use ($value) { | |
| 137 | 137 |                      $q->where('period_id', $value); | 
| 138 | 138 | }); | 
| 139 | 139 | }); | 
| 140 | 140 | }, | 
| 141 | -          function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) | |
| 141 | +          function() { // if the filter is NOT active (the GET parameter "checkbox" does not exit) | |
| 142 | 142 | }); | 
| 143 | 143 | |
| 144 | - CRUD::addFilter([ // select2_multiple filter | |
| 144 | + CRUD::addFilter([// select2_multiple filter | |
| 145 | 145 | 'name' => 'notenrolled', | 
| 146 | 146 | 'type' => 'select2_multiple', | 
| 147 | 147 |              'label'=> __('Is Not Enrolled in'), | 
| 148 | -        ], function () { // the options that show up in the select2 | |
| 148 | +        ], function() { // the options that show up in the select2 | |
| 149 | 149 |              return Period::all()->pluck('name', 'id')->toArray(); | 
| 150 | -        }, function ($values) { // if the filter is active | |
| 150 | +        }, function($values) { // if the filter is active | |
| 151 | 151 |              foreach (json_decode($values) as $key => $value) { | 
| 152 | -                $this->crud->query = $this->crud->query->whereDoesntHave('enrollments', function ($query) use ($value) { | |
| 153 | -                    return $query->whereHas('course', function ($q) use ($value) { | |
| 152 | +                $this->crud->query = $this->crud->query->whereDoesntHave('enrollments', function($query) use ($value) { | |
| 153 | +                    return $query->whereHas('course', function($q) use ($value) { | |
| 154 | 154 |                          $q->where('period_id', $value); | 
| 155 | 155 | }); | 
| 156 | 156 | }); | 
| @@ -162,9 +162,9 @@ discard block | ||
| 162 | 162 | 'name' => 'institution_id', | 
| 163 | 163 | 'type' => 'select2', | 
| 164 | 164 |              'label' => __('Institution'), | 
| 165 | -        ], function () { | |
| 165 | +        ], function() { | |
| 166 | 166 |              return Institution::all()->pluck('name', 'id')->toArray(); | 
| 167 | -        }, function ($value) { // if the filter is active | |
| 167 | +        }, function($value) { // if the filter is active | |
| 168 | 168 |              $this->crud->addClause('where', 'institution_id', $value); | 
| 169 | 169 | }); | 
| 170 | 170 | } | 
| @@ -173,7 +173,7 @@ discard block | ||
| 173 | 173 |      { | 
| 174 | 174 | $student = Student::findOrFail($student); | 
| 175 | 175 | |
| 176 | -        if (! backpack_user()->isTeacher() && ! backpack_user()->can('enrollments.view')) { | |
| 176 | +        if (!backpack_user()->isTeacher() && !backpack_user()->can('enrollments.view')) { | |
| 177 | 177 | abort(403); | 
| 178 | 178 | } | 
| 179 | 179 | |
| @@ -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() | 
| @@ -86,52 +86,52 @@ | ||
| 86 | 86 | |
| 87 | 87 | ]); | 
| 88 | 88 | |
| 89 | - CRUD::addFilter([ // select2 filter | |
| 89 | + CRUD::addFilter([// select2 filter | |
| 90 | 90 | 'name' => 'rhythm_id', | 
| 91 | 91 | 'type' => 'select2', | 
| 92 | 92 |              'label'=> __('Rhythm'), | 
| 93 | -        ], function () { | |
| 93 | +        ], function() { | |
| 94 | 94 |              return Rhythm::all()->pluck('name', 'id')->toArray(); | 
| 95 | -        }, function ($value) { // if the filter is active | |
| 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) | |
| 98 | +          function() { // if the filter is NOT active (the GET parameter "checkbox" does not exit) | |
| 99 | 99 | }); | 
| 100 | 100 | |
| 101 | - CRUD::addFilter([ // select2 filter | |
| 101 | + CRUD::addFilter([// select2 filter | |
| 102 | 102 | 'name' => 'teacher_id', | 
| 103 | 103 | 'type' => 'select2', | 
| 104 | 104 |              'label'=> __('Teacher'), | 
| 105 | -        ], function () { | |
| 105 | +        ], function() { | |
| 106 | 106 |              return Teacher::all()->pluck('name', 'id')->toArray(); | 
| 107 | -        }, function ($value) { // if the filter is active | |
| 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) | |
| 110 | +          function() { // if the filter is NOT active (the GET parameter "checkbox" does not exit) | |
| 111 | 111 | }); | 
| 112 | 112 | |
| 113 | - CRUD::addFilter([ // select2 filter | |
| 113 | + CRUD::addFilter([// select2 filter | |
| 114 | 114 | 'name' => 'level_id', | 
| 115 | 115 | 'type' => 'select2', | 
| 116 | 116 |              'label'=> __('Level'), | 
| 117 | -        ], function () { | |
| 117 | +        ], function() { | |
| 118 | 118 |              return Level::all()->pluck('name', 'id')->toArray(); | 
| 119 | -        }, function ($value) { // if the filter is active | |
| 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) | |
| 122 | +          function() { // if the filter is NOT active (the GET parameter "checkbox" does not exit) | |
| 123 | 123 | }); | 
| 124 | 124 | |
| 125 | - CRUD::addFilter([ // select2 filter | |
| 125 | + CRUD::addFilter([// select2 filter | |
| 126 | 126 | 'name' => 'period_id', | 
| 127 | 127 | 'type' => 'select2', | 
| 128 | 128 |              'label'=> __('Period'), | 
| 129 | -        ], function () { | |
| 129 | +        ], function() { | |
| 130 | 130 |              return Period::all()->sortByDesc('id')->pluck('name', 'id')->toArray(); | 
| 131 | -        }, function ($value) { // if the filter is active | |
| 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) | |
| 134 | +          function() { // if the filter is NOT active (the GET parameter "checkbox" does not exit) | |
| 135 | 135 | $period = Period::get_default_period()->id; | 
| 136 | 136 |                CRUD::addClause('where', 'period_id', $period); | 
| 137 | 137 | $this->crud->getRequest()->request->add(['period_id' => $period]); // to make the filter look active | 
| @@ -72,25 +72,25 @@ discard block | ||
| 72 | 72 | ], | 
| 73 | 73 | ]); | 
| 74 | 74 | |
| 75 | - CRUD::addFilter([ // select2 filter | |
| 75 | + CRUD::addFilter([// select2 filter | |
| 76 | 76 | 'name' => 'teacher_id', | 
| 77 | 77 | 'type' => 'select2', | 
| 78 | 78 |              'label'=> __('Teacher'), | 
| 79 | -        ], function () { | |
| 79 | +        ], function() { | |
| 80 | 80 |              return Teacher::all()->pluck('name', 'id')->toArray(); | 
| 81 | -        }, function ($value) { // if the filter is active | |
| 81 | +        }, function($value) { // if the filter is active | |
| 82 | 82 |              CRUD::addClause('where', 'teacher_id', $value); | 
| 83 | 83 | }, | 
| 84 | -          function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) | |
| 84 | +          function() { // if the filter is NOT active (the GET parameter "checkbox" does not exit) | |
| 85 | 85 | }); | 
| 86 | 86 | |
| 87 | - CRUD::addFilter([ // daterange filter | |
| 87 | + CRUD::addFilter([// daterange filter | |
| 88 | 88 | 'type' => 'date_range', | 
| 89 | 89 | 'name' => 'from_to', | 
| 90 | 90 |              'label'=> __('Date range'), | 
| 91 | 91 | ], | 
| 92 | 92 | false, | 
| 93 | -          function ($value) { // if the filter is active, apply these constraints | |
| 93 | +          function($value) { // if the filter is active, apply these constraints | |
| 94 | 94 | $dates = json_decode($value); | 
| 95 | 95 |                CRUD::addClause('where', 'date', '>=', $dates->from); | 
| 96 | 96 |                CRUD::addClause('where', 'date', '<=', $dates->to.' 23:59:59'); | 
| @@ -122,7 +122,7 @@ discard block | ||
| 122 | 122 | 'model' => LeaveType::class, // foreign key model | 
| 123 | 123 | ], | 
| 124 | 124 | |
| 125 | - [ // date_range | |
| 125 | + [// date_range | |
| 126 | 126 | 'name' => ['start_date', 'end_date'], // db columns for start_date & end_date | 
| 127 | 127 | 'label' => 'Event Date Range', | 
| 128 | 128 | 'type' => 'date_range', | 
| @@ -166,7 +166,7 @@ discard block | ||
| 166 | 166 | 'model' => LeaveType::class, // foreign key model | 
| 167 | 167 | ], | 
| 168 | 168 | |
| 169 | - [ // datepicker | |
| 169 | + [// datepicker | |
| 170 | 170 | 'name' => 'date', | 
| 171 | 171 | 'label' => 'Event Date', | 
| 172 | 172 | 'type' => 'date', |