src/DataType/ModelCollectionHandler.php
private function loadModels(array $items)
    {
        $classes = [];
        $results = [];

        // Retrieve a list of keys to load from each class.
        foreach ($items as $item) {
            if (!is_null($item['key'])) {
                $classes[$item['class']][] = $item['key'];
            }
        }

        // Iterate list of classes and load all records matching a key.
        foreach ($classes as $class => $keys) {
            $model = new $class();
            $results[$class] = $model->whereIn($model->getKeyName(), $keys)->get()->keyBy($model->getKeyName());
        }

        return $results;
    }
private function loadModels(array $items)
    {
        $classes = [];
        $results = [];

        // Retrieve a list of keys to load from each class.
        foreach ($items as $item) {
            if (!is_null($item['key'])) {
                $classes[$item['class']][] = $item['key'];
            }
        }

        // Iterate list of classes and load all records matching a key.
        foreach ($classes as $class => $keys) {
            $model = new $class();
            $results[$class] = $model->whereIn($model->getKeyName(), $keys)->get()->keyBy($model->getKeyName());
        }

        return $results;
    }
private function loadModels ( array $ items ) { $ classes = [ ] ; $ results = [ ] ; // Retrieve a list of keys to load from each class. foreach ( $ items as $ item ) { if ( ! is_null ( $ item [ 'key' ] ) ) { $ classes [ $ item [ 'class' ] ] [ ] = $ item [ 'key' ] ; } } // Iterate list of classes and load all records matching a key. foreach ( $ classes as $ class => $ keys ) { $ model = new $ class ( ) ; $ results [ $ class ] = $ model -> whereIn ( $ model -> getKeyName ( ) , $ keys ) -> get ( ) -> keyBy ( $ model -> getKeyName ( ) ) ; } return $ results ; }
Load each model instance, grouped by class.

@param array $items

@return array
Load each model instance grouped by class .