public function updateOrCreateBy(array $where, array $inputs = [])
    {
        $inputs = $this->purifyInputs($inputs);

        $query = $this->make();

        $query = $this->applyWhere($query, $where);

        $model = $query->first();

        if ($model) {
            $model->update($inputs);

            return $model;
        } else {
            return $this->model->create($inputs);
        }
    }
public function updateOrCreateBy(array $where, array $inputs = [])
    {
        $inputs = $this->purifyInputs($inputs);

        $query = $this->make();

        $query = $this->applyWhere($query, $where);

        $model = $query->first();

        if ($model) {
            $model->update($inputs);

            return $model;
        } else {
            return $this->model->create($inputs);
        }
    }
public function updateOrCreateBy ( array $ where , array $ inputs = [ ] ) { $ inputs = $ this -> purifyInputs ( $ inputs ) ; $ query = $ this -> make ( ) ; $ query = $ this -> applyWhere ( $ query , $ where ) ; $ model = $ query -> first ( ) ; if ( $ model ) { $ model -> update ( $ inputs ) ; return $ model ; } else { return $ this -> model -> create ( $ inputs ) ; } }
Update the record matching input parameters.
If no record is found, create a new one.

@param array $where
@param array $inputs

@return mixed
Update the record matching input parameters . If no record is found create a new one .