@@ -200,7 +200,7 @@ public function belongsTo($related, $foreignKey = null, $otherKey = null, $relat
200
200
return new BelongsTo ($ query , $ this , $ foreignKey , $ otherKey , $ relation );
201
201
}
202
202
203
- /**
203
+ /**
204
204
* Define a many-to-many relationship.
205
205
*
206
206
* @param string $related
@@ -211,8 +211,8 @@ public function belongsTo($related, $foreignKey = null, $otherKey = null, $relat
211
211
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
212
212
*/
213
213
public function belongsToMany ($ related , $ collection = null , $ foreignKey = null , $ otherKey = null , $ relation = null )
214
- {
215
- // If no relationship name was passed, we will pull backtraces to get the
214
+ {
215
+ // If no relationship name was passed, we will pull backtraces to get the
216
216
// name of the calling function. We will use that function name as the
217
217
// title of this relation since that is a great convention to apply.
218
218
if (is_null ($ relation ))
@@ -222,30 +222,30 @@ public function belongsToMany($related, $collection = null, $foreignKey = null,
222
222
$ name = $ caller ['function ' ];
223
223
}
224
224
225
- // First, we'll need to determine the foreign key and "other key" for the
226
- // relationship. Once we have determined the keys we'll make the query
227
- // instances as well as the relationship instances we need for this.
228
- $ foreignKey = $ foreignKey ?: $ this ->getForeignKey () . 's ' ;
225
+ // First, we'll need to determine the foreign key and "other key" for the
226
+ // relationship. Once we have determined the keys we'll make the query
227
+ // instances as well as the relationship instances we need for this.
228
+ $ foreignKey = $ foreignKey ?: $ this ->getForeignKey () . 's ' ;
229
229
230
- $ instance = new $ related ;
230
+ $ instance = new $ related ;
231
231
232
- $ otherKey = $ otherKey ?: $ instance ->getForeignKey () . 's ' ;
232
+ $ otherKey = $ otherKey ?: $ instance ->getForeignKey () . 's ' ;
233
233
234
- // If no table name was provided, we can guess it by concatenating the two
235
- // models using underscores in alphabetical order. The two model names
236
- // are transformed to snake case from their default CamelCase also.
237
- if (is_null ($ collection ))
238
- {
239
- $ collection = $ instance ->getTable ();
240
- }
234
+ // If no table name was provided, we can guess it by concatenating the two
235
+ // models using underscores in alphabetical order. The two model names
236
+ // are transformed to snake case from their default CamelCase also.
237
+ if (is_null ($ collection ))
238
+ {
239
+ $ collection = $ instance ->getTable ();
240
+ }
241
241
242
- // Now we're ready to create a new query builder for the related model and
243
- // the relationship instances for the relation. The relations will set
244
- // appropriate query constraint and entirely manages the hydrations.
245
- $ query = $ instance ->newQuery ();
242
+ // Now we're ready to create a new query builder for the related model and
243
+ // the relationship instances for the relation. The relations will set
244
+ // appropriate query constraint and entirely manages the hydrations.
245
+ $ query = $ instance ->newQuery ();
246
246
247
- return new BelongsToMany ($ query , $ this , $ collection , $ foreignKey , $ otherKey , $ relation );
248
- }
247
+ return new BelongsToMany ($ query , $ this , $ collection , $ foreignKey , $ otherKey , $ relation );
248
+ }
249
249
250
250
/**
251
251
* Get a new query builder instance for the connection.
0 commit comments