public function create(array $data){
        $model = $this->model->create($data);
        //check for hasMany
        if($this->validateRelationData($this->withHasMany,'many')){
            $model->{$this->withHasMany['relation']}()->saveMany($this->withHasMany['data']);
        }
        //check for belongsToMany
        if($this->validateRelationData($this->withBelongsToMany,'tomany')){
            $model->{$this->withBelongsToMany['relation']}()->sync($this->withBelongsToMany['data']);
        }
        return $model;
    }
public function create(array $data){
        $model = $this->model->create($data);
        //check for hasMany
        if($this->validateRelationData($this->withHasMany,'many')){
            $model->{$this->withHasMany['relation']}()->saveMany($this->withHasMany['data']);
        }
        //check for belongsToMany
        if($this->validateRelationData($this->withBelongsToMany,'tomany')){
            $model->{$this->withBelongsToMany['relation']}()->sync($this->withBelongsToMany['data']);
        }
        return $model;
    }
public function create ( array $ data ) { $ model = $ this -> model -> create ( $ data ) ; //check for hasMany if ( $ this -> validateRelationData ( $ this -> withHasMany , 'many' ) ) { $ model -> { $ this -> withHasMany [ 'relation' ] } ( ) -> saveMany ( $ this -> withHasMany [ 'data' ] ) ; } //check for belongsToMany if ( $ this -> validateRelationData ( $ this -> withBelongsToMany , 'tomany' ) ) { $ model -> { $ this -> withBelongsToMany [ 'relation' ] } ( ) -> sync ( $ this -> withBelongsToMany [ 'data' ] ) ; } return $ model ; }
Create new database entry including related models
@param array $data
@return Model
Create new database entry including related models