@@ -17,7 +17,7 @@ |
||
| 17 | 17 | private function setLocale(string $locale) |
| 18 | 18 | { |
| 19 | 19 | // Check if is allowed and set default locale if not |
| 20 | - if (! language()->allowed($locale)) { |
|
| 20 | + if (!language()->allowed($locale)) { |
|
| 21 | 21 | $locale = config('app.locale'); |
| 22 | 22 | } |
| 23 | 23 | |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | |
| 53 | 53 | $gradeType = GradeType::findOrFail($request->input('grade_type_id')); |
| 54 | 54 | |
| 55 | - if (! $course->grade_types->contains($gradeType->id)) { |
|
| 55 | + if (!$course->grade_types->contains($gradeType->id)) { |
|
| 56 | 56 | $course->grade_types()->attach($gradeType->id); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * a user is allowed to edit the course grades if they are the teacher for this course, |
| 31 | 31 | * or if they have explicit permission to do so |
| 32 | 32 | */ |
| 33 | - Gate::define('edit-course-grades', function ($user, $course) { |
|
| 33 | + Gate::define('edit-course-grades', function($user, $course) { |
|
| 34 | 34 | return $user->isTeacher() && $user->teacher_id == $course->teacher_id || $user->can('evaluation.edit'); |
| 35 | 35 | }); |
| 36 | 36 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * a user is allowed to view the course attendance sheet if they are the teacher for this course, |
| 39 | 39 | * or if they have explicit permission to view all course attendance sheets |
| 40 | 40 | */ |
| 41 | - Gate::define('view-course-attendance', function ($user, $course) { |
|
| 41 | + Gate::define('view-course-attendance', function($user, $course) { |
|
| 42 | 42 | return $user->isTeacher() && $user->teacher_id == $course->teacher_id || $user->can('attendance.view'); |
| 43 | 43 | }); |
| 44 | 44 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * if they are the teacher for this course, |
| 48 | 48 | * or if they have explicit permission to view all event attendance sheets |
| 49 | 49 | */ |
| 50 | - Gate::define('view-event-attendance', function ($user, $event) { |
|
| 50 | + Gate::define('view-event-attendance', function($user, $event) { |
|
| 51 | 51 | return ($event->teacher_id == $user->teacher_id) || ($event->course->teacher_id == $user->teacher_id) || $user->can('attendance.view'); |
| 52 | 52 | }); |
| 53 | 53 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * if they are the teacher for the course, |
| 57 | 57 | * or if they have explicit permission to edit any attendance sheets |
| 58 | 58 | */ |
| 59 | - Gate::define('edit-attendance', function ($user, $event) { |
|
| 59 | + Gate::define('edit-attendance', function($user, $event) { |
|
| 60 | 60 | return ($event->teacher_id == $user->teacher_id) || ($event->course->teacher_id == $user->teacher_id) || $user->can('attendance.edit'); |
| 61 | 61 | }); |
| 62 | 62 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * teachers are allowed to view their own calendar, |
| 65 | 65 | * and users with explicit permission can view all calendars |
| 66 | 66 | */ |
| 67 | - Gate::define('view-teacher-calendar', function ($user, $teacher) { |
|
| 67 | + Gate::define('view-teacher-calendar', function($user, $teacher) { |
|
| 68 | 68 | return ($user->isTeacher() && $user->teacher_id == $teacher->id) || $user->can('calendars.view'); |
| 69 | 69 | }); |
| 70 | 70 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * teachers are allowed to view their own courses, |
| 73 | 73 | * and users with explicit permission can view all courses |
| 74 | 74 | */ |
| 75 | - Gate::define('view-course', function ($user, Course $course) { |
|
| 75 | + Gate::define('view-course', function($user, Course $course) { |
|
| 76 | 76 | return ($user->isTeacher() && $user->teacher_id == $course->teacher_id) || $user->can('courses.view'); |
| 77 | 77 | }); |
| 78 | 78 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * if they are a teacher |
| 82 | 82 | * of if they have explicit permission to view any result |
| 83 | 83 | */ |
| 84 | - Gate::define('view-enrollment', function ($user, $enrollment) { |
|
| 84 | + Gate::define('view-enrollment', function($user, $enrollment) { |
|
| 85 | 85 | return ($user->isStudent() && $user->student_id == $enrollment->student_id) || $user->isTeacher() || $user->can('evaluation.view'); |
| 86 | 86 | }); |
| 87 | 87 | |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * if the user is the teacher of the course |
| 90 | 90 | * of if they have explicit permission to enroll students |
| 91 | 91 | */ |
| 92 | - Gate::define('enroll-in-course', function ($user, $course) { |
|
| 92 | + Gate::define('enroll-in-course', function($user, $course) { |
|
| 93 | 93 | return $course->teacher_id == $user->teacher_id || $user->can('enrollments.edit'); |
| 94 | 94 | }); |
| 95 | 95 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * if the user is a teacher |
| 98 | 98 | * of if they have explicit permission to enroll students |
| 99 | 99 | */ |
| 100 | - Gate::define('enroll-students', function ($user) { |
|
| 100 | + Gate::define('enroll-students', function($user) { |
|
| 101 | 101 | return $user->isTeacher() || $user->can('enrollments.edit'); |
| 102 | 102 | }); |
| 103 | 103 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * teachers are allowed to view their own hours, |
| 106 | 106 | * and users with explicit permission can view all hours |
| 107 | 107 | */ |
| 108 | - Gate::define('view-teacher-hours', function ($user, $teacher) { |
|
| 108 | + Gate::define('view-teacher-hours', function($user, $teacher) { |
|
| 109 | 109 | return ($user->isTeacher() && $user->teacher_id == $teacher->id) || $user->can('hr.view'); |
| 110 | 110 | }); |
| 111 | 111 | |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * teachers are allowed to edit results for their own students |
| 114 | 114 | * as well as users with explicit permission to edit any result |
| 115 | 115 | */ |
| 116 | - Gate::define('edit-result', function ($user, $enrollment) { |
|
| 116 | + Gate::define('edit-result', function($user, $enrollment) { |
|
| 117 | 117 | return ($user->isTeacher() && $user->teacher_id == $enrollment->course->teacher_id) || $user->can('evaluation.edit'); |
| 118 | 118 | }); |
| 119 | 119 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | { |
| 63 | 63 | CRUD::setValidation(StoreRequest::class); |
| 64 | 64 | CRUD::addFields([ |
| 65 | - [ // Select2 |
|
| 65 | + [// Select2 |
|
| 66 | 66 | 'label' => 'User', |
| 67 | 67 | 'type' => 'select2', |
| 68 | 68 | 'name' => 'id', // the db column for the foreign key |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | protected function setupUpdateOperation() |
| 88 | 88 | { |
| 89 | 89 | CRUD::addFields([ |
| 90 | - [ // Select2 |
|
| 90 | + [// Select2 |
|
| 91 | 91 | 'label' => 'User', |
| 92 | 92 | 'type' => 'select2', |
| 93 | 93 | 'name' => 'id', // the db column for the foreign key |
@@ -82,12 +82,12 @@ discard block |
||
| 82 | 82 | 'attribute' => 'lastname', // 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.id') |
| 87 | 87 | ->orderBy('users.lastname', $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('lastname', 'like', '%'.$searchTerm.'%'); |
| 92 | 92 | }); |
| 93 | 93 | }, |
@@ -102,12 +102,12 @@ discard block |
||
| 102 | 102 | 'attribute' => 'firstname', // 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.id') |
| 107 | 107 | ->orderBy('users.firstname', $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('firstname', 'like', '%'.$searchTerm.'%'); |
| 112 | 112 | }); |
| 113 | 113 | }, |
@@ -122,12 +122,12 @@ discard block |
||
| 122 | 122 | 'attribute' => 'email', // foreign key attribute that is shown to user |
| 123 | 123 | 'model' => 'App\Models\User', // foreign key model |
| 124 | 124 | 'orderable' => true, |
| 125 | - 'orderLogic' => function ($query, $column, $columnDirection) { |
|
| 125 | + 'orderLogic' => function($query, $column, $columnDirection) { |
|
| 126 | 126 | return $query->leftJoin('users', 'users.id', '=', 'students.id') |
| 127 | 127 | ->orderBy('users.email', $columnDirection)->select('students.*'); |
| 128 | 128 | }, |
| 129 | - 'searchLogic' => function ($query, $column, $searchTerm) { |
|
| 130 | - $query->orWhereHas('user', function ($q) use ($searchTerm) { |
|
| 129 | + 'searchLogic' => function($query, $column, $searchTerm) { |
|
| 130 | + $query->orWhereHas('user', function($q) use ($searchTerm) { |
|
| 131 | 131 | $q->where('email', 'like', '%'.$searchTerm.'%'); |
| 132 | 132 | }); |
| 133 | 133 | }, |
@@ -145,32 +145,32 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | ]); |
| 147 | 147 | |
| 148 | - CRUD::addFilter([ // select2 filter |
|
| 148 | + CRUD::addFilter([// select2 filter |
|
| 149 | 149 | 'name' => 'enrolled', |
| 150 | 150 | 'type' => 'select2', |
| 151 | 151 | 'label'=> __('Is Enrolled in'), |
| 152 | - ], function () { |
|
| 152 | + ], function() { |
|
| 153 | 153 | return Period::all()->pluck('name', 'id')->toArray(); |
| 154 | - }, function ($value) { // if the filter is active |
|
| 155 | - $this->crud->query = $this->crud->query->whereHas('enrollments', function ($query) use ($value) { |
|
| 156 | - return $query->whereHas('course', function ($q) use ($value) { |
|
| 154 | + }, function($value) { // if the filter is active |
|
| 155 | + $this->crud->query = $this->crud->query->whereHas('enrollments', function($query) use ($value) { |
|
| 156 | + return $query->whereHas('course', function($q) use ($value) { |
|
| 157 | 157 | $q->where('period_id', $value); |
| 158 | 158 | }); |
| 159 | 159 | }); |
| 160 | 160 | }, |
| 161 | - function () { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 161 | + function() { // if the filter is NOT active (the GET parameter "checkbox" does not exit) |
|
| 162 | 162 | }); |
| 163 | 163 | |
| 164 | - CRUD::addFilter([ // select2_multiple filter |
|
| 164 | + CRUD::addFilter([// select2_multiple filter |
|
| 165 | 165 | 'name' => 'notenrolled', |
| 166 | 166 | 'type' => 'select2_multiple', |
| 167 | 167 | 'label'=> __('Is Not Enrolled in'), |
| 168 | - ], function () { // the options that show up in the select2 |
|
| 168 | + ], function() { // the options that show up in the select2 |
|
| 169 | 169 | return Period::all()->pluck('name', 'id')->toArray(); |
| 170 | - }, function ($values) { // if the filter is active |
|
| 170 | + }, function($values) { // if the filter is active |
|
| 171 | 171 | foreach (json_decode($values) as $key => $value) { |
| 172 | - $this->crud->query = $this->crud->query->whereDoesntHave('enrollments', function ($query) use ($value) { |
|
| 173 | - return $query->whereHas('course', function ($q) use ($value) { |
|
| 172 | + $this->crud->query = $this->crud->query->whereDoesntHave('enrollments', function($query) use ($value) { |
|
| 173 | + return $query->whereHas('course', function($q) use ($value) { |
|
| 174 | 174 | $q->where('period_id', $value); |
| 175 | 175 | }); |
| 176 | 176 | }); |
@@ -182,9 +182,9 @@ discard block |
||
| 182 | 182 | 'name' => 'institution_id', |
| 183 | 183 | 'type' => 'select2', |
| 184 | 184 | 'label' => __('Institution'), |
| 185 | - ], function () { |
|
| 185 | + ], function() { |
|
| 186 | 186 | return Institution::all()->pluck('name', 'id')->toArray(); |
| 187 | - }, function ($value) { // if the filter is active |
|
| 187 | + }, function($value) { // if the filter is active |
|
| 188 | 188 | $this->crud->addClause('where', 'institution_id', $value); |
| 189 | 189 | }); |
| 190 | 190 | |
@@ -192,9 +192,9 @@ discard block |
||
| 192 | 192 | 'name' => 'status_type_id', |
| 193 | 193 | 'type' => 'select2', |
| 194 | 194 | 'label' => __('Lead Status'), |
| 195 | - ], function () { |
|
| 195 | + ], function() { |
|
| 196 | 196 | return LeadType::all()->pluck('name', 'id')->toArray(); |
| 197 | - }, function ($value) { |
|
| 197 | + }, function($value) { |
|
| 198 | 198 | $this->crud->addClause('computedLeadType', $value); |
| 199 | 199 | }); |
| 200 | 200 | } |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | { |
| 204 | 204 | $student = Student::findOrFail($student); |
| 205 | 205 | |
| 206 | - if (! backpack_user()->isTeacher() && ! backpack_user()->can('enrollments.view')) { |
|
| 206 | + if (!backpack_user()->isTeacher() && !backpack_user()->can('enrollments.view')) { |
|
| 207 | 207 | abort(403); |
| 208 | 208 | } |
| 209 | 209 | |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | parent::boot(); |
| 19 | 19 | |
| 20 | 20 | // before adding an event, we check that the teacher is available |
| 21 | - static::saving(function ($event) { |
|
| 21 | + static::saving(function($event) { |
|
| 22 | 22 | $teacher = Teacher::find($event->teacher_id); |
| 23 | 23 | // if the teacher is on leave on the day of the event |
| 24 | 24 | if ($event->teacher_id !== null && $teacher) { |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | parent::boot(); |
| 32 | 32 | |
| 33 | 33 | // when deleting a student, also delete any enrollments, grades and attendance related to this student |
| 34 | - static::deleting(function (self $student) { |
|
| 34 | + static::deleting(function(self $student) { |
|
| 35 | 35 | Attendance::where('student_id', $student->id)->delete(); |
| 36 | 36 | Enrollment::where('student_id', $student->id)->delete(); |
| 37 | 37 | }); |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | { |
| 42 | 42 | switch ($leadTypeId) { |
| 43 | 43 | case 1: // active / enrolled students |
| 44 | - return $query->whereHas('enrollments', function ($query) use ($leadTypeId) { |
|
| 45 | - return $query->whereHas('course', function ($q) use ($leadTypeId) { |
|
| 44 | + return $query->whereHas('enrollments', function($query) use ($leadTypeId) { |
|
| 45 | + return $query->whereHas('course', function($q) use ($leadTypeId) { |
|
| 46 | 46 | $q->where('period_id', Period::get_default_period()->id); |
| 47 | 47 | }); |
| 48 | 48 | }); |
@@ -56,18 +56,18 @@ discard block |
||
| 56 | 56 | case 4: // old students who have at least one enrollment |
| 57 | 57 | return $query |
| 58 | 58 | ->where('lead_type_id', $leadTypeId) |
| 59 | - ->orWhere(function ($query) use ($leadTypeId) { |
|
| 59 | + ->orWhere(function($query) use ($leadTypeId) { |
|
| 60 | 60 | $query |
| 61 | 61 | ->whereNull('lead_type_id') |
| 62 | - ->whereHas('enrollments', function ($query) use ($leadTypeId) { |
|
| 62 | + ->whereHas('enrollments', function($query) use ($leadTypeId) { |
|
| 63 | 63 | return $query |
| 64 | - ->whereHas('course', function ($q) use ($leadTypeId) { |
|
| 64 | + ->whereHas('course', function($q) use ($leadTypeId) { |
|
| 65 | 65 | $q->where('period_id', '!=', Period::get_default_period()->id); |
| 66 | 66 | }); |
| 67 | 67 | }) |
| 68 | - ->whereDoesntHave('enrollments', function ($query) use ($leadTypeId) { |
|
| 68 | + ->whereDoesntHave('enrollments', function($query) use ($leadTypeId) { |
|
| 69 | 69 | return $query |
| 70 | - ->whereHas('course', function ($q) use ($leadTypeId) { |
|
| 70 | + ->whereHas('course', function($q) use ($leadTypeId) { |
|
| 71 | 71 | $q->where('period_id', Period::get_default_period()->id); |
| 72 | 72 | }); |
| 73 | 73 | }); |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | return $this->hasMany(Attendance::class) |
| 106 | 106 | ->where('attendance_type_id', 4) // absence |
| 107 | - ->whereHas('event', function ($q) use ($period) { |
|
| 108 | - return $q->whereHas('course', function ($c) use ($period) { |
|
| 107 | + ->whereHas('event', function($q) use ($period) { |
|
| 108 | + return $q->whereHas('course', function($c) use ($period) { |
|
| 109 | 109 | return $c->where('period_id', $period->id); |
| 110 | 110 | }); |
| 111 | 111 | }); |
@@ -118,8 +118,8 @@ discard block |
||
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | return $this->hasMany(Attendance::class) |
| 121 | - ->whereHas('event', function ($q) use ($period) { |
|
| 122 | - return $q->whereHas('course', function ($c) use ($period) { |
|
| 121 | + ->whereHas('event', function($q) use ($period) { |
|
| 122 | + return $q->whereHas('course', function($c) use ($period) { |
|
| 123 | 123 | return $c->where('period_id', $period->id); |
| 124 | 124 | }); |
| 125 | 125 | }); |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | public function getIsEnrolledAttribute() |
| 212 | 212 | { |
| 213 | 213 | // if the student is currently enrolled |
| 214 | - if ($this->enrollments()->whereHas('course', function ($q) { |
|
| 214 | + if ($this->enrollments()->whereHas('course', function($q) { |
|
| 215 | 215 | return $q->where('period_id', Period::get_default_period()->id); |
| 216 | 216 | })->count() > 0) { |
| 217 | 217 | return 1; |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | parent::boot(); |
| 24 | 24 | |
| 25 | 25 | // when an attendance record is added, we check if this is an absence |
| 26 | - static::saved(function (self $attendance) { |
|
| 26 | + static::saved(function(self $attendance) { |
|
| 27 | 27 | if ($attendance->attendance_type_id == 4) { // todo move to configurable settings |
| 28 | 28 | // Log::info('Absence marked for student '.$attendance->student->name); |
| 29 | 29 | // will check the record again and send a notification if it hasn't changed |