src/RetrievesIntermediateTables.php
protected function hydrateIntermediateRelations(array $models)
    {
        $intermediateTables = $this->intermediateTables;

        ksort($intermediateTables);

        foreach ($intermediateTables as $accessor => $intermediateTable) {
            $prefix = $this->prefix($accessor);

            if (Str::contains($accessor, '.')) {
                [$path, $key] = preg_split('/\.(?=[^.]*$)/', $accessor);
            } else {
                [$path, $key] = [null, $accessor];
            }

            foreach ($models as $model) {
                $relation = $this->intermediateRelation($model, $intermediateTable, $prefix);

                data_get($model, $path)->setRelation($key, $relation);
            }
        }
    }
protected function hydrateIntermediateRelations(array $models)
    {
        $intermediateTables = $this->intermediateTables;

        ksort($intermediateTables);

        foreach ($intermediateTables as $accessor => $intermediateTable) {
            $prefix = $this->prefix($accessor);

            if (Str::contains($accessor, '.')) {
                [$path, $key] = preg_split('/\.(?=[^.]*$)/', $accessor);
            } else {
                [$path, $key] = [null, $accessor];
            }

            foreach ($models as $model) {
                $relation = $this->intermediateRelation($model, $intermediateTable, $prefix);

                data_get($model, $path)->setRelation($key, $relation);
            }
        }
    }
protected function hydrateIntermediateRelations ( array $ models ) { $ intermediateTables = $ this -> intermediateTables ; ksort ( $ intermediateTables ) ; foreach ( $ intermediateTables as $ accessor => $ intermediateTable ) { $ prefix = $ this -> prefix ( $ accessor ) ; if ( Str :: contains ( $ accessor , '.' ) ) { [ $ path , $ key ] = preg_split ( '/\.(?=[^.]*$)/' , $ accessor ) ; } else { [ $ path , $ key ] = [ null , $ accessor ] ; } foreach ( $ models as $ model ) { $ relation = $ this -> intermediateRelation ( $ model , $ intermediateTable , $ prefix ) ; data_get ( $ model , $ path ) -> setRelation ( $ key , $ relation ) ; } } }
Hydrate the intermediate table relationship on the models.

@param  array  $models
@return void
Hydrate the intermediate table relationship on the models .