File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 4
4
5
5
use ArrayAccess ;
6
6
use Illuminate \Support \Str ;
7
+ use Illuminate \Contracts \Support \Arrayable ;
7
8
use Illuminate \Database \Eloquent \Concerns \HasAttributes ;
8
9
use Illuminate \Database \Eloquent \Concerns \HidesAttributes ;
9
10
use Whitecube \LaravelFlexibleContent \Contracts \Layout as LayoutInterface ;
10
11
11
- class Layout implements LayoutInterface, ArrayAccess
12
+ class Layout implements LayoutInterface, ArrayAccess, Arrayable
12
13
{
13
14
use HasAttributes;
14
15
use HidesAttributes;
@@ -257,4 +258,14 @@ public function offsetUnset($attribute)
257
258
{
258
259
unset($ this ->attributes [$ attribute ]);
259
260
}
261
+
262
+ /**
263
+ * Convert the layout instance to an array.
264
+ *
265
+ * @return array
266
+ */
267
+ public function toArray ()
268
+ {
269
+ return $ this ->attributesToArray ();
270
+ }
260
271
}
Original file line number Diff line number Diff line change 48
48
expect ($ layout ->test )->toBeNull ();
49
49
expect ($ layout ['something ' ])->toBeNull ();
50
50
});
51
+
52
+ it ('can convert layout attributes to array ' , function () {
53
+ $ layout = (new Layout ())->key ('foo ' )->make (null , ['test ' => true , 'something ' => false ]);
54
+
55
+ $ converted = $ layout ->toArray ();
56
+
57
+ expect ($ converted )->toBeArray ();
58
+ expect ($ converted ['test ' ])->toBeTrue ();
59
+ expect ($ converted ['something ' ])->toBeFalse ();
60
+ });
You can’t perform that action at this time.
0 commit comments