@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | public function __invoke(Builder $query, $value, string $property) |
19 | 19 | { |
20 | 20 | $value = collect($value)->toArray(); |
21 | - $query->where(function (Builder $query) use ($value) { |
|
21 | + $query->where(function(Builder $query) use ($value) { |
|
22 | 22 | $query->whereIn('level_id', $value) |
23 | - ->orWhereHas('children', function (Builder $query) use ($value) { |
|
23 | + ->orWhereHas('children', function(Builder $query) use ($value) { |
|
24 | 24 | $query->whereIn('level_id', $value); |
25 | 25 | }); |
26 | 26 | }); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | public function search() |
57 | 57 | { |
58 | - return QueryBuilder::for(Course::class)->where('campus_id', 1) |
|
58 | + return QueryBuilder::for (Course::class)->where('campus_id', 1) |
|
59 | 59 | ->with('room')->withCount('events')->withCount('children')->withCount('enrollments') |
60 | 60 | ->allowedFilters([ |
61 | 61 | 'name', |
@@ -55,7 +55,8 @@ discard block |
||
55 | 55 | |
56 | 56 | public function search() |
57 | 57 | { |
58 | - return QueryBuilder::for(Course::class)->where('campus_id', 1) |
|
58 | + return QueryBuilder::for(Course::class) { |
|
59 | + ->where('campus_id', 1) |
|
59 | 60 | ->with('room')->withCount('events')->withCount('children')->withCount('enrollments') |
60 | 61 | ->allowedFilters([ |
61 | 62 | 'name', |
@@ -64,5 +65,6 @@ discard block |
||
64 | 65 | AllowedFilter::custom('searchable_levels', new FiltersSearchableLevels), |
65 | 66 | 'teacher_id', ]) |
66 | 67 | ->get(); |
68 | + } |
|
67 | 69 | } |
68 | 70 | } |
@@ -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 | }); |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | |
69 | 69 | return $this->hasMany(Attendance::class) |
70 | 70 | ->where('attendance_type_id', 4) // absence |
71 | - ->whereHas('event', function ($q) use ($period) { |
|
72 | - return $q->whereHas('course', function ($c) use ($period) { |
|
71 | + ->whereHas('event', function($q) use ($period) { |
|
72 | + return $q->whereHas('course', function($c) use ($period) { |
|
73 | 73 | return $c->where('period_id', $period->id); |
74 | 74 | }); |
75 | 75 | }); |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | return $this->hasMany(Attendance::class) |
85 | - ->whereHas('event', function ($q) use ($period) { |
|
86 | - return $q->whereHas('course', function ($c) use ($period) { |
|
85 | + ->whereHas('event', function($q) use ($period) { |
|
86 | + return $q->whereHas('course', function($c) use ($period) { |
|
87 | 87 | return $c->where('period_id', $period->id); |
88 | 88 | }); |
89 | 89 | }); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | public function getIsEnrolledAttribute() |
176 | 176 | { |
177 | 177 | // if the student is currently enrolled |
178 | - if ($this->enrollments()->whereHas('course', function ($q) { |
|
178 | + if ($this->enrollments()->whereHas('course', function($q) { |
|
179 | 179 | return $q->where('period_id', $this->currentPeriod); |
180 | 180 | })->count() > 0) { |
181 | 181 | return 1; |