@@ -6293,9 +6293,7 @@ public function encode(Document $collection, Document $document): Document
62936293 $ attributes = $ collection ->getAttribute ('attributes ' , []);
62946294
62956295 foreach ($ this ->getInternalAttributes () as $ attribute ) {
6296- if ($ attribute ['$id ' ] !== '$permissions ' ) { // Don't encode permissions into a JSON string
6297- $ attributes [] = new Document ($ attribute );
6298- }
6296+ $ attributes [] = $ attribute ;
62996297 }
63006298
63016299 foreach ($ attributes as $ attribute ) {
@@ -6305,6 +6303,13 @@ public function encode(Document $collection, Document $document): Document
63056303 $ filters = $ attribute ['filters ' ] ?? [];
63066304 $ value = $ document ->getAttribute ($ key );
63076305
6306+ if ($ attribute ['$id ' ] === '$permissions ' ) {
6307+ if (empty ($ value )){
6308+ $ document ->setAttribute ('$permissions ' , []); // set default value
6309+ }
6310+ continue ;
6311+ }
6312+
63086313 // Continue on optional param with no default
63096314 if (is_null ($ value ) && is_null ($ default )) {
63106315 continue ;
@@ -6370,12 +6375,13 @@ public function decode(Document $collection, Document $document, array $selectio
63706375 }
63716376
63726377 foreach ($ this ->getInternalAttributes () as $ attribute ) {
6373- if ($ attribute ['$id ' ] !== '$permissions ' ) {
6374- $ attributes [] = new Document ($ attribute );
6375- }
6378+ $ attributes [] = $ attribute ;
63766379 }
63776380
63786381 foreach ($ attributes as $ attribute ) {
6382+ // if ($attribute['$id'] === '$permissions') {
6383+ // continue;
6384+ // }
63796385 $ key = $ attribute ['$id ' ] ?? '' ;
63806386 $ array = $ attribute ['array ' ] ?? false ;
63816387 $ filters = $ attribute ['filters ' ] ?? [];
@@ -6428,12 +6434,13 @@ public function casting(Document $collection, Document $document): Document
64286434 $ attributes = $ collection ->getAttribute ('attributes ' , []);
64296435
64306436 foreach ($ this ->getInternalAttributes () as $ attribute ) {
6431- if ($ attribute ['$id ' ] !== '$permissions ' ) {
6432- $ attributes [] = new Document ($ attribute );
6433- }
6437+ $ attributes [] = $ attribute ;
64346438 }
64356439
64366440 foreach ($ attributes as $ attribute ) {
6441+ // if ($attribute['$id'] === '$permissions') {
6442+ // continue;
6443+ // }
64376444 $ key = $ attribute ['$id ' ] ?? '' ;
64386445 $ type = $ attribute ['type ' ] ?? '' ;
64396446 $ array = $ attribute ['array ' ] ?? false ;
0 commit comments