File tree Expand file tree Collapse file tree 1 file changed +20
-7
lines changed Expand file tree Collapse file tree 1 file changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -273,27 +273,40 @@ public function count()
273
273
274
274
275
275
/**
276
+ * @param bool $nested
276
277
* @return array
277
278
* @throws \Exception
278
279
*/
279
- public function toArray ()
280
+ public function toArray ($ nested = true )
280
281
{
281
282
$ ar = [];
282
283
283
- foreach ($ this ->items as $ item ){
284
+ if ($ nested ){
285
+ foreach ($ this ->items as $ item ){
286
+
287
+ if (! method_exists ($ item , 'toArray ' )){
288
+ throw new \Exception ('item class has not method toArray ' );
289
+ }
290
+ else {
291
+ $ ar [] = $ item ->toArray ();
292
+ }
284
293
285
- if (! method_exists ($ item , 'toArray ' )){
286
- throw new \Exception ('item class has not method toArray ' );
287
294
}
288
- else {
289
- $ ar [] = $ item ->toArray ();
295
+ }else {
296
+ foreach ($ this ->items as $ item ){
297
+ $ ar [] = $ item ;
290
298
}
291
-
292
299
}
293
300
301
+
294
302
return $ ar ;
295
303
}
304
+
296
305
306
+ /**
307
+ * @return array
308
+ * @throws \Exception
309
+ */
297
310
public function preview ()
298
311
{
299
312
$ ar = [];
You can’t perform that action at this time.
0 commit comments