Corcel\Model::belongsToMany PHP Method

belongsToMany() public method

Replace the original belongsToMany function to forward the connection name
public belongsToMany ( string $related, null $table = null, null $foreignKey = null, null $otherKey = null, null $relation = null ) : Illuminate\Database\Eloquent\Relations\BelongsToMany
$related string
$table null
$foreignKey null
$otherKey null
$relation null
return Illuminate\Database\Eloquent\Relations\BelongsToMany
    public function belongsToMany($related, $table = null, $foreignKey = null, $otherKey = null, $relation = null)
    {
        if (is_null($relation)) {
            $relation = $this->getBelongsToManyCaller();
        }
        $foreignKey = $foreignKey ?: $this->getForeignKey();
        $instance = new $related();
        if ($instance instanceof Model) {
            $instance->setConnection($this->getConnection()->getName());
        } else {
            $instance->setConnection($instance->getConnection()->getName());
        }
        $otherKey = $otherKey ?: $instance->getForeignKey();
        if (is_null($table)) {
            $table = $this->joiningTable($related);
        }
        $query = $instance->newQuery();
        return new BelongsToMany($query, $this, $table, $foreignKey, $otherKey, $relation);
    }