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

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

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

        if ($entity == null) {
            return $this->create($parameters);
        }

        $result = new Result();
        $result->getResources()->push($entity);

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

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

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

        if ($entity == null) {
            return $this->create($parameters);
        }

        $result = new Result();
        $result->getResources()->push($entity);

        return $result;
    }
public function findOrCreate ( $ criteria , $ parameters = null ) { if ( $ criteria instanceof Bag ) { $ criteria = $ criteria -> toArray ( ) ; } if ( $ parameters === null ) { $ parameters = $ criteria ; } $ parameters = $ this -> castParameters ( $ parameters ) ; $ entity = $ this -> getRepository ( ) -> findOneBy ( $ criteria ) ; if ( $ entity == null ) { return $ this -> create ( $ parameters ) ; } $ result = new Result ( ) ; $ result -> getResources ( ) -> push ( $ entity ) ; return $ result ; }
First or create.

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

@return ResultContract
First or create .