@@ -204,17 +204,20 @@ public function morphTo($name = null, $type = null, $id = null)
204
204
}
205
205
}
206
206
207
- / **
207
+ **
208
208
* Define a many-to-many relationship.
209
209
*
210
210
* @param string $ related
211
211
* @param string $ collection
212
- * @param string $foreignKey
213
- * @param string $otherKey
212
+ * @param string $ foreignPivotKey
213
+ * @param string $ relatedPivotKey
214
+ * @param string $ parentKey
215
+ * @param string $ relatedKey
214
216
* @param string $ relation
215
217
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
216
218
*/
217
- public function belongsToMany ($ related , $ collection = null , $ foreignKey = null , $ otherKey = null , $ relation = null )
219
+ public function belongsToMany ($ related , $ collection = null , $ foreignPivotKey = null , $ relatedPivotKey = null ,
220
+ $ parentKey = null , $ relatedKey = null , $ relation = null )
218
221
{
219
222
// If no relationship name was passed, we will pull backtraces to get the
220
223
// name of the calling function. We will use that function name as the
@@ -225,17 +228,18 @@ public function belongsToMany($related, $collection = null, $foreignKey = null,
225
228
226
229
// Check if it is a relation with an original model.
227
230
if (! is_subclass_of ($ related , \Jenssegers \Mongodb \Eloquent \Model::class)) {
228
- return parent ::belongsToMany ($ related , $ collection , $ foreignKey , $ otherKey , $ relation );
231
+ return parent ::belongsToMany ($ related , $ collection = null , $ foreignPivotKey = null , $ relatedPivotKey = null ,
232
+ $ parentKey = null , $ relatedKey = null , $ relation = null );
229
233
}
230
234
231
235
// First, we'll need to determine the foreign key and "other key" for the
232
236
// relationship. Once we have determined the keys we'll make the query
233
237
// instances as well as the relationship instances we need for this.
234
- $ foreignKey = $ foreignKey ?: $ this ->getForeignKey ().'s ' ;
238
+ $ foreignPivotKey = $ foreignPivotKey ?: $ this ->getForeignKey ().'s ' ;
235
239
236
240
$ instance = new $ related ;
237
241
238
- $ otherKey = $ otherKey ?: $ instance ->getForeignKey ().'s ' ;
242
+ $ relatedPivotKey = $ relatedPivotKey ?: $ instance ->getForeignKey ().'s ' ;
239
243
240
244
// If no table name was provided, we can guess it by concatenating the two
241
245
// models using underscores in alphabetical order. The two model names
@@ -249,7 +253,9 @@ public function belongsToMany($related, $collection = null, $foreignKey = null,
249
253
// appropriate query constraint and entirely manages the hydrations.
250
254
$ query = $ instance ->newQuery ();
251
255
252
- return new BelongsToMany ($ query , $ this , $ collection , $ foreignKey , $ otherKey , $ relation );
256
+ return new BelongsToMany ($ query , $ this , $ collection ,
257
+ $ foreignPivotKey , $ relatedPivotKey ,
258
+ $ parentKey , $ relatedKey , $ relation );
253
259
}
254
260
255
261
/**
0 commit comments