Skip to content

Commit

Permalink
fix missing things
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Feb 13, 2017
1 parent b900c41 commit 7c7c3bc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ public function morphMany($related, $name, $type = null, $id = null, $localKey =
* @param string $table
* @param string $foreignKey
* @param string $relatedKey
* @param string $localKey
* @param string $relation
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
Expand All @@ -307,8 +308,6 @@ public function belongsToMany($related, $table = null, $foreignKey = null, $rela

$relatedKey = $relatedKey ?: $instance->getForeignKey();

$localKey = $localKey ?: $this->getKeyName();

// If no table name was provided, we can guess it by concatenating the two
// models using underscores in alphabetical order. The two model names
// are transformed to snake case from their default CamelCase also.
Expand All @@ -317,7 +316,8 @@ public function belongsToMany($related, $table = null, $foreignKey = null, $rela
}

return new BelongsToMany(
$instance->newQuery(), $this, $table, $foreignKey, $relatedKey, $localKey, $relation
$instance->newQuery(), $this, $table, $foreignKey,
$relatedKey, $localKey ?: $this->getKeyName(), $relation
);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,17 @@ class BelongsToMany extends Relation
* @param string $table
* @param string $foreignKey
* @param string $relatedKey
* @param string $localKey
* @param string $relationName
* @return void
*/
public function __construct(Builder $query, Model $parent, $table, $foreignKey, $relatedKey, $localKey, $relationName = null)
{
$this->table = $table;
$this->localKey = $localKey;
$this->relatedKey = $relatedKey;
$this->foreignKey = $foreignKey;
$this->relationName = $relationName;
$this->localKey = $localKey;

parent::__construct($query, $parent);
}
Expand Down
1 change: 1 addition & 0 deletions src/Illuminate/Database/Eloquent/Relations/MorphToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class MorphToMany extends BelongsToMany
* @param string $table
* @param string $foreignKey
* @param string $relatedKey
* @param string $localKey
* @param string $relationName
* @param bool $inverse
* @return void
Expand Down

0 comments on commit 7c7c3bc

Please sign in to comment.