@@ -134,12 +134,6 @@ public function morphMany($related, $name, $type = null, $id = null, $localKey =
134
134
*/
135
135
public function belongsTo ($ related , $ foreignKey = null , $ otherKey = null , $ relation = null )
136
136
{
137
- // Check if it is a relation with an original model.
138
- if (!is_subclass_of ($ related , 'Jenssegers\Mongodb\Model ' ))
139
- {
140
- return parent ::belongsTo ($ related , $ foreignKey , $ otherKey , $ relation );
141
- }
142
-
143
137
// If no relation name was given, we will use this debug backtrace to extract
144
138
// the calling method's name and use that as the relationship name as most
145
139
// of the time this will be what we desire to use for the relatinoships.
@@ -149,6 +143,12 @@ public function belongsTo($related, $foreignKey = null, $otherKey = null, $relat
149
143
150
144
$ relation = $ caller ['function ' ];
151
145
}
146
+
147
+ // Check if it is a relation with an original model.
148
+ if (!is_subclass_of ($ related , 'Jenssegers\Mongodb\Model ' ))
149
+ {
150
+ return parent ::belongsTo ($ related , $ foreignKey , $ otherKey , $ relation );
151
+ }
152
152
153
153
// If no foreign key was supplied, we can use a backtrace to guess the proper
154
154
// foreign key name by using the name of the relationship function, which
@@ -227,19 +227,19 @@ public function morphTo($name = null, $type = null, $id = null)
227
227
*/
228
228
public function belongsToMany ($ related , $ collection = null , $ foreignKey = null , $ otherKey = null , $ relation = null )
229
229
{
230
- // Check if it is a relation with an original model.
231
- if (!is_subclass_of ($ related , 'Jenssegers\Mongodb\Model ' ))
232
- {
233
- return parent ::belongsToMany ($ related , $ collection , $ foreignKey , $ otherKey , $ relation );
234
- }
235
-
236
230
// If no relationship name was passed, we will pull backtraces to get the
237
231
// name of the calling function. We will use that function name as the
238
232
// title of this relation since that is a great convention to apply.
239
233
if (is_null ($ relation ))
240
234
{
241
235
$ relation = $ this ->getBelongsToManyCaller ();
242
236
}
237
+
238
+ // Check if it is a relation with an original model.
239
+ if (!is_subclass_of ($ related , 'Jenssegers\Mongodb\Model ' ))
240
+ {
241
+ return parent ::belongsToMany ($ related , $ collection , $ foreignKey , $ otherKey , $ relation );
242
+ }
243
243
244
244
// First, we'll need to determine the foreign key and "other key" for the
245
245
// relationship. Once we have determined the keys we'll make the query
0 commit comments