public function create(array $attributes = [])
    {
        $this->fill($attributes);

        if (empty($this->getDn())) {
            // If the model doesn't currently have a distinguished
            // name set, we'll create one automatically using
            // the current query builders base DN.
            $dn = $this->getCreatableDn();

            // If the dn we receive is the same as our queries base DN, we need
            // to throw an exception. The LDAP object must have a valid RDN.
            if ($dn->get() == $this->query->getDn()) {
                throw new UnexpectedValueException("An LDAP object must have a valid RDN to be created. '$dn' given.");
            }

            $this->setDn($dn);
        }

        $this->fireModelEvent(new Events\Creating($this));

        // Create the entry.
        $created = $this->query->getConnection()->add($this->getDn(), $this->getCreatableAttributes());

        if ($created) {
            // If the entry was created we'll re-sync
            // the models attributes from the server.
            $this->syncRaw();

            $this->fireModelEvent(new Events\Created($this));

            return true;
        }

        return false;
    }
public function create(array $attributes = [])
    {
        $this->fill($attributes);

        if (empty($this->getDn())) {
            // If the model doesn't currently have a distinguished
            // name set, we'll create one automatically using
            // the current query builders base DN.
            $dn = $this->getCreatableDn();

            // If the dn we receive is the same as our queries base DN, we need
            // to throw an exception. The LDAP object must have a valid RDN.
            if ($dn->get() == $this->query->getDn()) {
                throw new UnexpectedValueException("An LDAP object must have a valid RDN to be created. '$dn' given.");
            }

            $this->setDn($dn);
        }

        $this->fireModelEvent(new Events\Creating($this));

        // Create the entry.
        $created = $this->query->getConnection()->add($this->getDn(), $this->getCreatableAttributes());

        if ($created) {
            // If the entry was created we'll re-sync
            // the models attributes from the server.
            $this->syncRaw();

            $this->fireModelEvent(new Events\Created($this));

            return true;
        }

        return false;
    }
public function create ( array $ attributes = [ ] ) { $ this -> fill ( $ attributes ) ; if ( empty ( $ this -> getDn ( ) ) ) { // If the model doesn't currently have a distinguished // name set, we'll create one automatically using // the current query builders base DN. $ dn = $ this -> getCreatableDn ( ) ; // If the dn we receive is the same as our queries base DN, we need // to throw an exception. The LDAP object must have a valid RDN. if ( $ dn -> get ( ) == $ this -> query -> getDn ( ) ) { throw new UnexpectedValueException ( "An LDAP object must have a valid RDN to be created. '$dn' given." ) ; } $ this -> setDn ( $ dn ) ; } $ this -> fireModelEvent ( new Events \ Creating ( $ this ) ) ; // Create the entry. $ created = $ this -> query -> getConnection ( ) -> add ( $ this -> getDn ( ) , $ this -> getCreatableAttributes ( ) ) ; if ( $ created ) { // If the entry was created we'll re-sync // the models attributes from the server. $ this -> syncRaw ( ) ; $ this -> fireModelEvent ( new Events \ Created ( $ this ) ) ; return true ; } return false ; }
Creates the entry in LDAP.

@param array $attributes The attributes for the new entry.

@throws UnexpectedValueException

@return bool
Creates the entry in LDAP .