Skip to content

Commit 7eb766c

Browse files
Enhance Fluent
1 parent 109a967 commit 7eb766c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Diff for: src/Illuminate/Support/Fluent.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Illuminate\Support\Traits\InteractsWithData;
99
use Illuminate\Support\Traits\Macroable;
1010
use JsonSerializable;
11+
use Traversable;
1112

1213
/**
1314
* @template TKey of array-key
@@ -36,7 +37,11 @@ class Fluent implements Arrayable, ArrayAccess, Jsonable, JsonSerializable
3637
*/
3738
public function __construct($attributes = [])
3839
{
39-
$this->fill($attributes);
40+
if (! $attributes instanceof Traversable) {
41+
$attributes = is_object($attributes) ? get_object_vars($attributes) : $attributes;
42+
}
43+
44+
$this->attributes = is_array($attributes) ? $attributes : iterator_to_array($attributes);
4045
}
4146

4247
/**

0 commit comments

Comments
 (0)