public function save(array $new_attributes = array(), $forceSave = false)
    {
        $options = array();

        if (array_key_exists('touch', $new_attributes))
        {
            $options['touch'] = $new_attributes['touch'];
            $new_attributes = array_except($new_attributes, array('touch'));
        }

        $this->fill($new_attributes);
        
        $this->beforeSave();

        if (! $forceSave)
        {
            // If the validation failed, return false
            if (! $this->valid && ! $this->validate())
                return false;
        }

        // Purge unnecessary fields
        $this->purgeUnneeded();

        // Auto hash passwords
        $this->autoHash();

        $this->saved = true;

        return parent::save($options);
    }
public function save(array $new_attributes = array(), $forceSave = false)
    {
        $options = array();

        if (array_key_exists('touch', $new_attributes))
        {
            $options['touch'] = $new_attributes['touch'];
            $new_attributes = array_except($new_attributes, array('touch'));
        }

        $this->fill($new_attributes);
        
        $this->beforeSave();

        if (! $forceSave)
        {
            // If the validation failed, return false
            if (! $this->valid && ! $this->validate())
                return false;
        }

        // Purge unnecessary fields
        $this->purgeUnneeded();

        // Auto hash passwords
        $this->autoHash();

        $this->saved = true;

        return parent::save($options);
    }
public function save ( array $ new_attributes = array ( ) , $ forceSave = false ) { $ options = array ( ) ; if ( array_key_exists ( 'touch' , $ new_attributes ) ) { $ options [ 'touch' ] = $ new_attributes [ 'touch' ] ; $ new_attributes = array_except ( $ new_attributes , array ( 'touch' ) ) ; } $ this -> fill ( $ new_attributes ) ; $ this -> beforeSave ( ) ; if ( ! $ forceSave ) { // If the validation failed, return false if ( ! $ this -> valid && ! $ this -> validate ( ) ) return false ; } // Purge unnecessary fields $ this -> purgeUnneeded ( ) ; // Auto hash passwords $ this -> autoHash ( ) ; $ this -> saved = true ; return parent :: save ( $ options ) ; }
Prepare before the Model is actually saved

@param array $new_attributes New attributes to fill onto the model before saving
@param bool  $forceSave      Whether to validate or not. Defaults to validating before saving

@return bool
Prepare before the Model is actually saved