diff --git a/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php b/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php index d15b70ddccbe..b54340ec2559 100755 --- a/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php +++ b/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php @@ -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; @@ -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); }