File tree Expand file tree Collapse file tree 1 file changed +17
-17
lines changed
starship/RestfullYii/ARBehaviors Expand file tree Collapse file tree 1 file changed +17
-17
lines changed Original file line number Diff line number Diff line change @@ -115,23 +115,23 @@ public function preSaveHelper($model)
115115
116116 foreach ($ model ->metadata ->relations as $ key =>$ value )
117117 {
118- if ( $ model ->hasRelated ($ key ) ) {
119- if ( array_key_exists (0 , $ model ->{$ key }) ) {
120- $ relation_data = [];
121- foreach ($ model ->{$ key } as $ index =>$ attributes ) {
122- if (!is_object ($ attributes )) {
123- $ relation_data [$ index ] = $ relation_helper ($ key , $ attributes );
124- } else {
125- $ relation_data [ $ index ] = $ attributes ;
126- }
127- }
128- $ model ->{ $ key } = $ relation_data ;
129- } else if ( is_array ( $ model ->{ $ key })){
130- if ( $ model ->$ key != []) {
131- $ model -> $ key = $ relation_helper ( $ key , $ model ->$ key);
132- }
133- }
134- }
118+ if ( $ model ->hasRelated ($ key ) && is_array ( $ model ->{ $ key }) ) {
119+ if ( array_key_exists (0 , $ model ->{$ key }) ) {
120+ $ relation_data = [];
121+ foreach ($ model ->{$ key } as $ index =>$ attributes ) {
122+ if (!is_object ($ attributes )) {
123+ $ relation_data [$ index ] = $ relation_helper (
124+ $ key , $ attributes
125+ ) ;
126+ } else {
127+ $ relation_data [ $ index ] = $ attributes ;
128+ }
129+ }
130+ $ model ->{ $ key} = $ relation_data ;
131+ } else if ( is_array ( $ model ->{ $ key})){
132+ $ model -> $ key = $ relation_helper ( $ key , $ model -> $ key );
133+ }
134+ }
135135 }
136136 return $ model ;
137137 }
You can’t perform that action at this time.
0 commit comments