This commit is contained in:
F4ilji
2025-04-23 20:45:25 +05:00
parent 43e59e8838
commit 1df1a1390f
@@ -50,26 +50,23 @@ class ClientAdditionalEducationController extends Controller
function () use ($request) { function () use ($request) {
$query = AdditionalEducationCategory::query() $query = AdditionalEducationCategory::query()
->has('additionalEducations') ->has('additionalEducations')
->WithActivePrograms() ->withActivePrograms()
->where('is_active', true) ->where('is_active', true);
->when($request->input('form'), function ($q, $form) {
$formValue = FormEducation::fromName($form)->value; if ($request->has('form')) {
$q->whereHas('additionalEducations', fn ($q) => $q->where('form_education', $formValue)) $formValue = FormEducation::fromName($request->form)->value;
->with(['additionalEducations' => fn ($q) => $q->where('form_education', $formValue)]); $query->whereHas('additionalEducations', fn ($q) => $q->where('form_education', $formValue))
}) ->with(['additionalEducations' => fn ($q) => $q->where('form_education', $formValue)]);
->when($request->input('category'), function($q, $slugs) { }
$q->whereIn('slug', $slugs);
}) if ($request->has('category')) {
->when($request->direction, function ($q, $direction) use ($request) { $slugs = is_array($request->category) ? $request->category : [$request->category];
return $q->whereHas('direction', fn($query) => $query->where('slug', $direction)) $query->whereIn('slug', $slugs);
->when($request->form, fn($query, $form) => $query->whereHas('additionalEducations', fn($q) => $q->where('form_education', FormEducation::fromName($form)) }
)
->when($request->category, fn($query) => is_array($request->category) if ($request->has('direction')) {
? $query->whereIn('slug', $request->category) $query->whereHas('direction', fn($q) => $q->where('slug', $request->direction));
: $query->where('slug', $request->category) }
)
->has('additionalEducations'));
});
return AdditionalEducationCategoryResource::collection($query->get()); return AdditionalEducationCategoryResource::collection($query->get());
} }