@@ -38,27 +38,32 @@ public static function fromModel(Model $model)
3838 }
3939
4040 public function toModel ()
41+ {
42+ return self ::makeModelFromContract ($ this );
43+ }
44+
45+ public static function makeModelFromContract (EntryContract $ source )
4146 {
4247 $ class = app ('statamic.eloquent.entries.model ' );
4348
44- $ data = $ this ->data ();
49+ $ data = $ source ->data ();
4550
4651 $ attributes = [
47- 'origin_id ' => $ this ->origin ()?->id(),
48- 'site ' => $ this ->locale (),
49- 'slug ' => $ this ->slug (),
50- 'uri ' => $ this ->uri (),
51- 'date ' => $ this ->hasDate () ? $ this ->date () : null ,
52- 'collection ' => $ this ->collectionHandle (),
53- 'blueprint ' => $ this ->blueprint ?? $ this ->blueprint ()->handle (),
52+ 'origin_id ' => $ source ->origin ()?->id(),
53+ 'site ' => $ source ->locale (),
54+ 'slug ' => $ source ->slug (),
55+ 'uri ' => $ source ->uri (),
56+ 'date ' => $ source ->hasDate () ? $ source ->date () : null ,
57+ 'collection ' => $ source ->collectionHandle (),
58+ 'blueprint ' => $ source ->blueprint ?? $ source ->blueprint ()->handle (),
5459 'data ' => $ data ->except (EntryQueryBuilder::COLUMNS ),
55- 'published ' => $ this ->published (),
56- 'status ' => $ this ->status (),
57- 'updated_at ' => $ this ->lastModified (),
58- 'order ' => $ this ->order (),
60+ 'published ' => $ source ->published (),
61+ 'status ' => $ source ->status (),
62+ 'updated_at ' => $ source ->lastModified (),
63+ 'order ' => $ source ->order (),
5964 ];
6065
61- if ($ id = $ this ->id ()) {
66+ if ($ id = $ source ->id ()) {
6267 $ attributes ['id ' ] = $ id ;
6368 }
6469
0 commit comments