diff --git a/app/Http/Controllers/CommunityVolunteers/API/CommunityVolunteerController.php b/app/Http/Controllers/CommunityVolunteers/API/CommunityVolunteerController.php index 67050ec25..21e00b5b3 100644 --- a/app/Http/Controllers/CommunityVolunteers/API/CommunityVolunteerController.php +++ b/app/Http/Controllers/CommunityVolunteers/API/CommunityVolunteerController.php @@ -136,7 +136,6 @@ public function store(StoreCommunityVolunteer $request): JsonResponse ]); } - public function show(CommunityVolunteer $cmtyvol): JsonResource { $this->authorize('view', $cmtyvol); @@ -170,4 +169,33 @@ public function destroy(CommunityVolunteer $cmtyvol): JsonResponse ]); } + public function languages(Request $request): array + { + return CommunityVolunteer::query() + ->when($request->has('activeOnly'), fn ($qry) => $qry->workStatus('active')) + ->select('languages') + ->distinct() + ->whereNotNull('languages') + ->orderBy('languages') + ->get() + ->pluck('languages') + ->flatten() + ->unique() + ->sort() + ->values() + ->toArray(); + } + + public function pickupLocations(Request $request): array + { + return CommunityVolunteer::query() + ->when($request->has('activeOnly'), fn ($qry) => $qry->workStatus('active')) + ->select('pickup_location') + ->distinct() + ->orderBy('pickup_location') + ->whereNotNull('pickup_location') + ->get() + ->pluck('pickup_location') + ->toArray(); + } } diff --git a/app/Http/Controllers/CommunityVolunteers/ListController.php b/app/Http/Controllers/CommunityVolunteers/ListController.php index e4c86c8ab..9a4d3715f 100644 --- a/app/Http/Controllers/CommunityVolunteers/ListController.php +++ b/app/Http/Controllers/CommunityVolunteers/ListController.php @@ -6,7 +6,6 @@ use App\Models\CommunityVolunteers\Responsibility; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Support\Collection; use Illuminate\Support\Facades\DB; use Illuminate\Validation\Rule; use Illuminate\View\View; diff --git a/resources/js/api/cmtyvol/cmtyvol.js b/resources/js/api/cmtyvol/cmtyvol.js index 100ffaafa..301f9978f 100644 --- a/resources/js/api/cmtyvol/cmtyvol.js +++ b/resources/js/api/cmtyvol/cmtyvol.js @@ -20,6 +20,16 @@ export default { const url = route('api.cmtyvol.destroy', id) return await api.delete(url) }, + async languages (activeOnly) { + let params = activeOnly ? { activeOnly: true } : {} + const url = route('api.cmtyvol.languages', params) + return await api.get(url) + }, + async pickupLocations (activeOnly) { + let params = activeOnly ? { activeOnly: true } : {} + const url = route('api.cmtyvol.pickupLocations', params) + return await api.get(url) + }, async ageDistribution () { const url = route('api.cmtyvol.ageDistribution') return await api.get(url) diff --git a/resources/js/components/cmtyvol/CmtyvolForm.vue b/resources/js/components/cmtyvol/CmtyvolForm.vue index e70f6fc12..54bb90e7b 100644 --- a/resources/js/components/cmtyvol/CmtyvolForm.vue +++ b/resources/js/components/cmtyvol/CmtyvolForm.vue @@ -197,9 +197,11 @@ + @@ -382,13 +384,15 @@ + - +