public static function hydrateRecursive(Model $model, array $items, Relation $parentRelation = null)
    {
        $instance = $model;

        $items = array_map(function ($item) use ($instance, $parentRelation) {
            // Convert all null relations into empty arrays
            $item = $item ?: [];
            
            return static::newFromBuilderRecursive($instance, $item, $parentRelation);
        }, $items);

        return $instance->newCollection($items);
    }
public static function hydrateRecursive(Model $model, array $items, Relation $parentRelation = null)
    {
        $instance = $model;

        $items = array_map(function ($item) use ($instance, $parentRelation) {
            // Convert all null relations into empty arrays
            $item = $item ?: [];
            
            return static::newFromBuilderRecursive($instance, $item, $parentRelation);
        }, $items);

        return $instance->newCollection($items);
    }
public static function hydrateRecursive ( Model $ model , array $ items , Relation $ parentRelation = null ) { $ instance = $ model ; $ items = array_map ( function ( $ item ) use ( $ instance , $ parentRelation ) { // Convert all null relations into empty arrays $ item = $ item ? : [ ] ; return static :: newFromBuilderRecursive ( $ instance , $ item , $ parentRelation ) ; } , $ items ) ; return $ instance -> newCollection ( $ items ) ; }
Create a collection of models from plain arrays recursive.

@param  \Illuminate\Database\Eloquent\Model $model
@param  \Illuminate\Database\Eloquent\Relations\Relation $parentRelation
@param  array $items
@return \Illuminate\Database\Eloquent\Collection
Create a collection of models from plain arrays recursive .