public function withHasMany(array $data, $relatedModel, $relation_name){
        $this->withHasMany['relation'] = $relation_name;
        foreach($data as $k=>$v){
            $this->withHasMany['data'][] = new $relatedModel($v);
        }
        return $this;
    }
public function withHasMany(array $data, $relatedModel, $relation_name){
        $this->withHasMany['relation'] = $relation_name;
        foreach($data as $k=>$v){
            $this->withHasMany['data'][] = new $relatedModel($v);
        }
        return $this;
    }
public function withHasMany ( array $ data , $ relatedModel , $ relation_name ) { $ this -> withHasMany [ 'relation' ] = $ relation_name ; foreach ( $ data as $ k => $ v ) { $ this -> withHasMany [ 'data' ] [ ] = new $ relatedModel ( $ v ) ; } return $ this ; }
Set related models that need to be created
for a hasMany relationship
@param array $data
@param string $relatedModel
@return self
Set related models that need to be created for a hasMany relationship