Skip to content

Commit

Permalink
check if AsPivot trait is used (#35271)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gummibeer committed Nov 18, 2020
1 parent 31e080c commit abea927
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Database\Eloquent\Relations\Concerns\AsPivot;
use Illuminate\Support\Str;
use InvalidArgumentException;

Expand Down Expand Up @@ -177,7 +178,7 @@ protected function resolveTableName($table)
return $table;
}

if ($model instanceof Pivot) {
if (in_array(AsPivot::class, class_uses_recursive($model))) {
$this->using($table);
}

Expand Down

0 comments on commit abea927

Please sign in to comment.