File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed
Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -10,13 +10,28 @@ trait Arrayable
1010
1111 public static function makeAttribute (array $ attributes = [])
1212 {
13- $ instance = new static ();
13+ $ instance = new class implements \ArrayAccess
14+ {
15+ use Arrayable;
16+ };
1417
15- $ instance ->attributes = $ attributes ;
18+ $ instance ->setAttributes ( $ attributes) ;
1619
1720 return $ instance ;
1821 }
1922
23+ public function setAttributes (array $ attributes = [])
24+ {
25+ $ this ->attributes = $ attributes ;
26+
27+ return $ this ;
28+ }
29+
30+ public function getAttributes ()
31+ {
32+ return $ this ->attributes ;
33+ }
34+
2035 public function offsetExists (mixed $ offset ): bool
2136 {
2237 return Arr::has ($ this ->attributes , $ offset );
@@ -54,6 +69,6 @@ public function __get(string $attribute): mixed
5469
5570 public function toArray ()
5671 {
57- return $ this ->attributes ;
72+ return $ this ->getAttributes () ;
5873 }
5974}
You can’t perform that action at this time.
0 commit comments