diff --git a/app/Http/Controllers/ProfilesApiController.php b/app/Http/Controllers/ProfilesApiController.php index 2c641d91..fe53e6c8 100644 --- a/app/Http/Controllers/ProfilesApiController.php +++ b/app/Http/Controllers/ProfilesApiController.php @@ -54,6 +54,10 @@ public function index(ProfilesApiRequest $request): JsonResponse $profile = $profile->withAnyTags(explode(';', $request->tag), Profile::class); } + if ($request->boolean('accepting_undergrad')) { + $profile = $profile->acceptingUndergradStudents(); + } + if ($request->boolean('with_data')) { if(count(array_filter($request->query())) <=1){ return response()->json(['error' => 'Please use a filter when pulling data.'], 400); diff --git a/app/Profile.php b/app/Profile.php index 04f34c7b..48cffa67 100644 --- a/app/Profile.php +++ b/app/Profile.php @@ -510,6 +510,24 @@ public function scopeStudentsPendingReviewWithSemester($query, $semester) $query_students->WithStatusPendingReview(); }); } + /** + * Query scope for Profiles that are accepting undergrad students, + * i.e. not marked as "Not accepting undergrad students" nor "Not accepting students". + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @return \Illuminate\Database\Eloquent\Builder + */ + public function scopeAcceptingUndergradStudents($query) { + return $query + ->whereDoesntHave("information", function ($q) { + $q->whereJsonContains("data->not_accepting_students", "1"); + }) + ->whereDoesntHave("information", function ($q) { + $q->whereJsonContains("data->show_not_accepting_students", "1") + ->whereJsonContains("data->not_accepting_students", "0") + ->whereJsonContains("data->not_accepting_grad_students", "0"); + }); + } /////////////////////////////////// // Mutators & Virtual Attributes // diff --git a/public/js/app.js b/public/js/app.js index 8b9b4d0a..11414b38 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -395,6 +395,9 @@ var profiles = function ($, undefined) { if ($select.data('school')) { api += '&from_school=' + $select.data('school'); } + if ($select.data('accepting-undergrad')) { + api += '&accepting_undergrad=' + $select.data('accepting-undergrad'); + } var profileSearch = new Bloodhound({ datumTokenizer: function datumTokenizer(profiles) { return Bloodhound.tokenizers.whitespace(profiles.value); diff --git a/public/mix-manifest.json b/public/mix-manifest.json index de5f1463..6f0ff1fc 100644 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -1,5 +1,5 @@ { - "/js/app.js": "/js/app.js?id=24be537863fbbe2259218dfb56ecef72", + "/js/app.js": "/js/app.js?id=3968f8a7c8b8f9af96296f3b18ea02c0", "/js/manifest.js": "/js/manifest.js?id=dc9ead3d7857b522d7de22d75063453c", "/css/app.css": "/css/app.css?id=bff46e69abe7a97b008296b99e4abadd", "/js/vendor.js": "/js/vendor.js?id=4d3313683b3a2faf8ca0278ce47f3880" diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index c187b44f..2ec52a95 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -352,6 +352,10 @@ var profiles = (function ($, undefined) { api += '&from_school=' + $select.data('school'); } + if ($select.data('accepting-undergrad')) { + api += '&accepting_undergrad=' + $select.data('accepting-undergrad'); + } + let profileSearch = new Bloodhound({ datumTokenizer: (profiles) => Bloodhound.tokenizers.whitespace(profiles.value), queryTokenizer: Bloodhound.tokenizers.whitespace, diff --git a/resources/views/students/form.blade.php b/resources/views/students/form.blade.php index 36f1a927..3e5e1b0d 100644 --- a/resources/views/students/form.blade.php +++ b/resources/views/students/form.blade.php @@ -77,6 +77,7 @@ 'aria-labelledby' => 'profiles-picker-label', 'multiple', 'required', + 'data-accepting-undergrad' => 'true', ] + ($schools->isNotEmpty() ? ['data-school' => $schools->keys()->implode(';')] : [])) !!} @else