src/RetrievesIntermediateTables.php
protected function intermediateRelation(Model $model, array $intermediateTable, $prefix)
    {
        $attributes = $this->intermediateAttributes($model, $prefix);

        $class = $intermediateTable['class'];

        if ($class === Pivot::class) {
            return $class::fromAttributes($model, $attributes, $intermediateTable['table'], true);
        }

        if (is_subclass_of($class, Pivot::class)) {
            return $class::fromRawAttributes($model, $attributes, $intermediateTable['table'], true);
        }

        /** @var \Illuminate\Database\Eloquent\Model $instance */
        $instance = new $class;

        return $instance->newFromBuilder($attributes);
    }
protected function intermediateRelation(Model $model, array $intermediateTable, $prefix)
    {
        $attributes = $this->intermediateAttributes($model, $prefix);

        $class = $intermediateTable['class'];

        if ($class === Pivot::class) {
            return $class::fromAttributes($model, $attributes, $intermediateTable['table'], true);
        }

        if (is_subclass_of($class, Pivot::class)) {
            return $class::fromRawAttributes($model, $attributes, $intermediateTable['table'], true);
        }

        /** @var \Illuminate\Database\Eloquent\Model $instance */
        $instance = new $class;

        return $instance->newFromBuilder($attributes);
    }
protected function intermediateRelation ( Model $ model , array $ intermediateTable , $ prefix ) { $ attributes = $ this -> intermediateAttributes ( $ model , $ prefix ) ; $ class = $ intermediateTable [ 'class' ] ; if ( $ class === Pivot :: class ) { return $ class :: fromAttributes ( $ model , $ attributes , $ intermediateTable [ 'table' ] , true ) ; } if ( is_subclass_of ( $ class , Pivot :: class ) ) { return $ class :: fromRawAttributes ( $ model , $ attributes , $ intermediateTable [ 'table' ] , true ) ; } /** @var \Illuminate\Database\Eloquent\Model $instance */ $ instance = new $ class ; return $ instance -> newFromBuilder ( $ attributes ) ; }
Get the intermediate relationship from the query.

@param  \Illuminate\Database\Eloquent\Model  $model
@param  array  $intermediateTable
@param  string  $prefix
@return \Illuminate\Database\Eloquent\Model
Get the intermediate relationship from the query .