@@ -37,15 +37,15 @@ public function hydrate(): array
3737 $ hydrated = [];
3838
3939 foreach ($ this ->entities as $ entity ) {
40- $ data = $ entity ->toArray ();
40+ $ data = $ entity ->getRawOriginal ();
4141 $ instance = Entity::instanceFromType ($ entity ->type );
4242
4343 if ($ instance instanceof Page) {
4444 $ data ['text ' ] = $ data ['description ' ];
4545 unset($ data ['description ' ]);
4646 }
4747
48- $ instance-> forceFill ($ data );
48+ $ instance = $ instance -> setRawAttributes ($ data, true );
4949 $ hydrated [] = $ instance ;
5050 }
5151
@@ -131,20 +131,21 @@ protected function loadParentsIntoModels(array $entities): void
131131 }
132132 });
133133
134- $ parents = $ filtered ? (new EntityHydrator ($ parentQuery ->get ()->all ()))->hydrate () : [];
134+ $ parentModels = $ filtered ? $ parentQuery ->get ()->all () : [];
135+ $ parents = (new EntityHydrator ($ parentModels ))->hydrate ();
135136 $ parentMap = [];
136137 foreach ($ parents as $ parent ) {
137138 $ parentMap [$ parent ->type . ': ' . $ parent ->id ] = $ parent ;
138139 }
139140
140141 foreach ($ entities as $ entity ) {
141142 if ($ entity instanceof Page || $ entity instanceof Chapter) {
142- $ key = 'book: ' . $ entity ->getAttribute ('book_id ' );
143- $ entity ->setRelation ('book ' , $ parentMap [$ key ] ?? null );
143+ $ key = 'book: ' . $ entity ->getRawAttribute ('book_id ' );
144+ $ entity ->setAttribute ('book ' , $ parentMap [$ key ] ?? null );
144145 }
145146 if ($ entity instanceof Page) {
146- $ key = 'chapter: ' . $ entity ->getAttribute ('chapter_id ' );
147- $ entity ->setRelation ('chapter ' , $ parentMap [$ key ] ?? null );
147+ $ key = 'chapter: ' . $ entity ->getRawAttribute ('chapter_id ' );
148+ $ entity ->setAttribute ('chapter ' , $ parentMap [$ key ] ?? null );
148149 }
149150 }
150151 }
0 commit comments