Code Duplication    Length = 26-26 lines in 2 locations

src/Form/Field/HasMany.php 1 location

@@ 291-316 (lines=26) @@
288
     *
289
     * @return array
290
     */
291
    protected function formatValidationAttribute($input, $label, $column)
292
    {
293
        $new = $attributes = [];
294
295
        if (is_array($column)) {
296
            foreach ($column as $index => $col) {
297
                $new[$col.$index] = $col;
298
            }
299
        }
300
301
        foreach (array_keys(array_dot($input)) as $key) {
302
            if (is_string($column)) {
303
                if (Str::endsWith($key, ".$column")) {
304
                    $attributes[$key] = $label;
305
                }
306
            } else {
307
                foreach ($new as $k => $val) {
308
                    if (Str::endsWith($key, ".$k")) {
309
                        $attributes[$key] = $label."[$val]";
310
                    }
311
                }
312
            }
313
        }
314
315
        return $attributes;
316
    }
317
318
    /**
319
     * Reset input key for validation.

src/Form/Field/Embeds.php 1 location

@@ 253-278 (lines=26) @@
250
     *
251
     * @return array
252
     */
253
    protected function formatValidationAttribute($input, $label, $column)
254
    {
255
        $new = $attributes = [];
256
257
        if (is_array($column)) {
258
            foreach ($column as $index => $col) {
259
                $new[$col.$index] = $col;
260
            }
261
        }
262
263
        foreach (array_keys(array_dot($input)) as $key) {
264
            if (is_string($column)) {
265
                if (Str::endsWith($key, ".$column")) {
266
                    $attributes[$key] = $label;
267
                }
268
            } else {
269
                foreach ($new as $k => $val) {
270
                    if (Str::endsWith($key, ".$k")) {
271
                        $attributes[$key] = $label."[$val]";
272
                    }
273
                }
274
            }
275
        }
276
277
        return $attributes;
278
    }
279
280
    /**
281
     * Reset input key for validation.