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 @@