route('user')?->id ?? $this->route('user'); return [ 'name' => ['sometimes', 'required', 'string', 'max:255'], 'username' => [ 'nullable', 'string', 'max:255', Rule::unique('users', 'username')->ignore($userId), ], 'email' => [ 'sometimes', 'required', 'email', 'max:255', Rule::unique('users', 'email')->ignore($userId), ], 'whatsapp_number' => ['nullable', 'string', 'max:20'], 'password' => ['nullable', 'string', 'min:8'], 'is_master' => ['nullable', 'boolean'], 'is_platform_staff' => ['nullable', 'boolean'], 'access_level' => ['sometimes', 'required', Rule::enum(UserAccessLevel::class)], 'status' => ['sometimes', 'required', Rule::in(['active', 'inactive', 'suspended'])], 'user_profile' => ['nullable', 'array'], 'user_profile.nik' => ['nullable', 'string', 'max:30'], 'user_profile.address' => ['nullable', 'string'], 'user_profile.provinsi_id' => ['nullable', 'integer', 'exists:wilayah_provinsi,id'], 'user_profile.kabupaten_id' => [ 'nullable', 'integer', Rule::exists('wilayah_kabupaten', 'id')->where( 'provinsi_id', $this->input('user_profile.provinsi_id') ), ], 'user_profile.kecamatan_id' => [ 'nullable', 'integer', Rule::exists('wilayah_kecamatan', 'id')->where( 'kabupaten_id', $this->input('user_profile.kabupaten_id') ), ], 'user_profile.desa_id' => [ 'nullable', 'integer', Rule::exists('wilayah_desa', 'id')->where( 'kecamatan_id', $this->input('user_profile.kecamatan_id') ), ], 'user_tenants' => ['nullable', 'array'], 'user_tenants.*.tenant_id' => ['required_with:user_tenants', 'integer', 'exists:tenants,id'], 'user_tenants.*.role' => ['nullable', Rule::in(['customer', 'staff', 'tenant_owner'])], 'user_tenants.*.is_default' => ['nullable', 'boolean'], 'user_menu_groups' => ['nullable', 'array'], 'user_menu_groups.*.menu_group_id' => ['required_with:user_menu_groups', 'integer', 'exists:menu_groups,id'], 'user_menu_groups.*.tenant_id' => ['nullable', 'integer', 'exists:tenants,id'], ]; } }