public function updateOrCreate($criteria, $parameters = null)
    {
        if ($criteria instanceof Bag) {
            $criteria = $criteria->toArray();
        }

        if ($parameters === null) {
            $parameters = $criteria;
        }

        $parameters = $this->castParameters($parameters);
        $entity = $this->getRepository()->findOneBy($criteria);

        return $entity !== null ? $this->update($entity, $parameters) : $this->create($parameters->merge($criteria));
    }
public function updateOrCreate($criteria, $parameters = null)
    {
        if ($criteria instanceof Bag) {
            $criteria = $criteria->toArray();
        }

        if ($parameters === null) {
            $parameters = $criteria;
        }

        $parameters = $this->castParameters($parameters);
        $entity = $this->getRepository()->findOneBy($criteria);

        return $entity !== null ? $this->update($entity, $parameters) : $this->create($parameters->merge($criteria));
    }
public function updateOrCreate ( $ criteria , $ parameters = null ) { if ( $ criteria instanceof Bag ) { $ criteria = $ criteria -> toArray ( ) ; } if ( $ parameters === null ) { $ parameters = $ criteria ; } $ parameters = $ this -> castParameters ( $ parameters ) ; $ entity = $ this -> getRepository ( ) -> findOneBy ( $ criteria ) ; return $ entity !== null ? $ this -> update ( $ entity , $ parameters ) : $ this -> create ( $ parameters -> merge ( $ criteria ) ) ; }
Update or create.

@param Bag|array $criteria
@param Bag|array $parameters

@return ResultContract
Update or create .