Commit b358f631 authored by Jens Segers's avatar Jens Segers

Converting tabs to spaces

parent c777e31a
...@@ -200,7 +200,7 @@ abstract class Model extends \Illuminate\Database\Eloquent\Model { ...@@ -200,7 +200,7 @@ abstract class Model extends \Illuminate\Database\Eloquent\Model {
return new BelongsTo($query, $this, $foreignKey, $otherKey, $relation); return new BelongsTo($query, $this, $foreignKey, $otherKey, $relation);
} }
/** /**
* Define a many-to-many relationship. * Define a many-to-many relationship.
* *
* @param string $related * @param string $related
...@@ -211,8 +211,8 @@ abstract class Model extends \Illuminate\Database\Eloquent\Model { ...@@ -211,8 +211,8 @@ abstract class Model extends \Illuminate\Database\Eloquent\Model {
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/ */
public function belongsToMany($related, $collection = null, $foreignKey = null, $otherKey = null, $relation = null) public function belongsToMany($related, $collection = null, $foreignKey = null, $otherKey = null, $relation = null)
{ {
// If no relationship name was passed, we will pull backtraces to get the // If no relationship name was passed, we will pull backtraces to get the
// name of the calling function. We will use that function name as the // name of the calling function. We will use that function name as the
// title of this relation since that is a great convention to apply. // title of this relation since that is a great convention to apply.
if (is_null($relation)) if (is_null($relation))
...@@ -222,30 +222,30 @@ abstract class Model extends \Illuminate\Database\Eloquent\Model { ...@@ -222,30 +222,30 @@ abstract class Model extends \Illuminate\Database\Eloquent\Model {
$name = $caller['function']; $name = $caller['function'];
} }
// First, we'll need to determine the foreign key and "other key" for the // First, we'll need to determine the foreign key and "other key" for the
// relationship. Once we have determined the keys we'll make the query // relationship. Once we have determined the keys we'll make the query
// instances as well as the relationship instances we need for this. // instances as well as the relationship instances we need for this.
$foreignKey = $foreignKey ?: $this->getForeignKey() . 's'; $foreignKey = $foreignKey ?: $this->getForeignKey() . 's';
$instance = new $related; $instance = new $related;
$otherKey = $otherKey ?: $instance->getForeignKey() . 's'; $otherKey = $otherKey ?: $instance->getForeignKey() . 's';
// If no table name was provided, we can guess it by concatenating the two // If no table name was provided, we can guess it by concatenating the two
// models using underscores in alphabetical order. The two model names // models using underscores in alphabetical order. The two model names
// are transformed to snake case from their default CamelCase also. // are transformed to snake case from their default CamelCase also.
if (is_null($collection)) if (is_null($collection))
{ {
$collection = $instance->getTable(); $collection = $instance->getTable();
} }
// Now we're ready to create a new query builder for the related model and // Now we're ready to create a new query builder for the related model and
// the relationship instances for the relation. The relations will set // the relationship instances for the relation. The relations will set
// appropriate query constraint and entirely manages the hydrations. // appropriate query constraint and entirely manages the hydrations.
$query = $instance->newQuery(); $query = $instance->newQuery();
return new BelongsToMany($query, $this, $collection, $foreignKey, $otherKey, $relation); return new BelongsToMany($query, $this, $collection, $foreignKey, $otherKey, $relation);
} }
/** /**
* Get a new query builder instance for the connection. * Get a new query builder instance for the connection.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment