public function findOrInit($conditions = false, $data = array())
    {
        if (!$this->find($conditions)) {
            // Reset status when record not found
            $this->isNew = true;

            !is_array($conditions) && $conditions = array($this->primaryKey => $conditions);

            // Convert to object to array
            if (is_object($data) && method_exists($data, 'toArray')) {
                $data = $data->toArray();
            }

            // conditions data are fillable
            $this->fromArray($data);
            $this->setData($conditions);
        }
        return $this;
    }
public function findOrInit($conditions = false, $data = array())
    {
        if (!$this->find($conditions)) {
            // Reset status when record not found
            $this->isNew = true;

            !is_array($conditions) && $conditions = array($this->primaryKey => $conditions);

            // Convert to object to array
            if (is_object($data) && method_exists($data, 'toArray')) {
                $data = $data->toArray();
            }

            // conditions data are fillable
            $this->fromArray($data);
            $this->setData($conditions);
        }
        return $this;
    }
public function findOrInit ( $ conditions = false , $ data = array ( ) ) { if ( ! $ this -> find ( $ conditions ) ) { // Reset status when record not found $ this -> isNew = true ; ! is_array ( $ conditions ) && $ conditions = array ( $ this -> primaryKey => $ conditions ) ; // Convert to object to array if ( is_object ( $ data ) && method_exists ( $ data , 'toArray' ) ) { $ data = $ data -> toArray ( ) ; } // conditions data are fillable $ this -> fromArray ( $ data ) ; $ this -> setData ( $ conditions ) ; } return $ this ; }
Find a record by specified conditions and init with the specified data if record not found

@param mixed $conditions
@param array $data
@return $this
Find a record by specified conditions and init with the specified data if record not found