src/Concerns/HasAttributes.php
public function setDefaultValuesForAttributes()
    {
        // Only works on new models.
        if ($this->exists) {
            return $this;
        }

        // Defaults on attributes.
        $defaults = $this->getAttributesFromSchema('default', true);

        // Remove attributes that have been given values.
        $defaults = array_except($defaults, array_keys($this->getDirty()));

        // Unguard.
        static::unguard();

        // Allocate values.
        foreach ($defaults as $key => $value) {
            $this->{$key} = $value;
        }

        // Reguard.
        static::reguard();

        return $this;
    }
public function setDefaultValuesForAttributes()
    {
        // Only works on new models.
        if ($this->exists) {
            return $this;
        }

        // Defaults on attributes.
        $defaults = $this->getAttributesFromSchema('default', true);

        // Remove attributes that have been given values.
        $defaults = array_except($defaults, array_keys($this->getDirty()));

        // Unguard.
        static::unguard();

        // Allocate values.
        foreach ($defaults as $key => $value) {
            $this->{$key} = $value;
        }

        // Reguard.
        static::reguard();

        return $this;
    }
public function setDefaultValuesForAttributes ( ) { // Only works on new models. if ( $ this -> exists ) { return $ this ; } // Defaults on attributes. $ defaults = $ this -> getAttributesFromSchema ( 'default' , true ) ; // Remove attributes that have been given values. $ defaults = array_except ( $ defaults , array_keys ( $ this -> getDirty ( ) ) ) ; // Unguard. static :: unguard ( ) ; // Allocate values. foreach ( $ defaults as $ key => $ value ) { $ this -> { $ key } = $ value ; } // Reguard. static :: reguard ( ) ; return $ this ; }
Set default values on this attribute.

@return $this
Set default values on this attribute .