Skip to content

Commit

Permalink
Use the custom pivot model in MorphToMany::newPivot (#17862)
Browse files Browse the repository at this point in the history
  • Loading branch information
ntzm authored and taylorotwell committed Feb 10, 2017
1 parent 57eacff commit 8f3b091
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Illuminate/Database/Eloquent/Relations/MorphToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ protected function newPivotQuery()
*/
public function newPivot(array $attributes = [], $exists = false)
{
$pivot = new MorphPivot($this->parent, $attributes, $this->table, $exists);
$using = $this->using;

$pivot = $using ? new $using($this->parent, $attributes, $this->table, $exists)
: new MorphPivot($this->parent, $attributes, $this->table, $exists);

$pivot->setPivotKeys($this->foreignKey, $this->relatedKey)
->setMorphType($this->morphType)
Expand Down

0 comments on commit 8f3b091

Please sign in to comment.