public function purgeAttributes()
    {
        // Get the attribute keys
        $keys = array_keys($this->getAttributes());

        // Filter out keys that should purged
        $attributes = array_filter($keys, function ($key) {
            // Remove attributes that should be purged
            if (in_array($key, $this->getPurgeable())) {
                return false;
            }

            // Remove attributes ending with _confirmation
            if (Str::endsWith($key, '_confirmation')) {
                return false;
            }

            // Remove attributes starting with _ prefix
            if (Str::startsWith($key, '_')) {
                return false;
            }

            return true;
        });

        // Keep only the attributes that were not purged
        $this->attributes = array_intersect_key($this->getAttributes(), array_flip($attributes));
    }
public function purgeAttributes()
    {
        // Get the attribute keys
        $keys = array_keys($this->getAttributes());

        // Filter out keys that should purged
        $attributes = array_filter($keys, function ($key) {
            // Remove attributes that should be purged
            if (in_array($key, $this->getPurgeable())) {
                return false;
            }

            // Remove attributes ending with _confirmation
            if (Str::endsWith($key, '_confirmation')) {
                return false;
            }

            // Remove attributes starting with _ prefix
            if (Str::startsWith($key, '_')) {
                return false;
            }

            return true;
        });

        // Keep only the attributes that were not purged
        $this->attributes = array_intersect_key($this->getAttributes(), array_flip($attributes));
    }
public function purgeAttributes ( ) { // Get the attribute keys $ keys = array_keys ( $ this -> getAttributes ( ) ) ; // Filter out keys that should purged $ attributes = array_filter ( $ keys , function ( $ key ) { // Remove attributes that should be purged if ( in_array ( $ key , $ this -> getPurgeable ( ) ) ) { return false ; } // Remove attributes ending with _confirmation if ( Str :: endsWith ( $ key , '_confirmation' ) ) { return false ; } // Remove attributes starting with _ prefix if ( Str :: startsWith ( $ key , '_' ) ) { return false ; } return true ; } ) ; // Keep only the attributes that were not purged $ this -> attributes = array_intersect_key ( $ this -> getAttributes ( ) , array_flip ( $ attributes ) ) ; }
Unset attributes that should be purged.
Unset attributes that should be purged .