From c3ed5a0edbd9bed89ef61b613d4d1cc2721ee166 Mon Sep 17 00:00:00 2001 From: mirivlad Date: Mon, 30 Mar 2026 11:12:50 +0800 Subject: [PATCH] =?UTF-8?q?Fix:=20=D0=9E=D0=B1=D1=89=D0=B0=D1=8F=20=D0=B3?= =?UTF-8?q?=D1=80=D1=83=D0=BF=D0=BF=D0=B0=20=D1=82=D0=B5=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D1=8C=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D1=91=D1=82=D1=81=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ required_if валидация для organization_id ✅ JavaScript убирает required при выборе общей группы ✅ Очищает значение при переключении на общую группу Co-authored-by: Qwen-Coder --- .../Controllers/Admin/GroupUserController.php | 7 +------ resources/views/admin/groups/create.blade.php | 16 +++++++++++++++- .../views/components/searchable-select.blade.php | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/Admin/GroupUserController.php b/app/Http/Controllers/Admin/GroupUserController.php index 16385b5..2b7a346 100755 --- a/app/Http/Controllers/Admin/GroupUserController.php +++ b/app/Http/Controllers/Admin/GroupUserController.php @@ -56,17 +56,12 @@ class GroupUserController extends Controller $validated = $request->validate([ 'group_type' => 'required|in:organization,general', - 'organization_id' => 'nullable|exists:organizations,id', + 'organization_id' => 'required_if:group_type,organization|nullable|exists:organizations,id', 'name' => 'required|string|max:255', 'description' => 'nullable|string', 'is_active' => 'boolean', ]); - // Для группы организации organization_id обязательна - if ($validated['group_type'] === 'organization' && empty($validated['organization_id'])) { - return back()->withErrors(['organization_id' => 'Выберите организацию для группы'])->withInput(); - } - Group::create([ 'organization_id' => $validated['group_type'] === 'organization' ? $validated['organization_id'] : null, 'name' => $validated['name'], diff --git a/resources/views/admin/groups/create.blade.php b/resources/views/admin/groups/create.blade.php index c73b1b6..d97b82a 100755 --- a/resources/views/admin/groups/create.blade.php +++ b/resources/views/admin/groups/create.blade.php @@ -82,7 +82,21 @@