public function with_guarded( $attribute, $callback ) {

		if ( is_array( $attribute ) ) {
			$attributes = $attribute;
		} else {
			$attributes = func_get_args();
			$callback   = array_pop( $attributes );
		}

		$unguarded = static::$_unguarded;

		if ( $unguarded ) {
			static::$_unguarded = false;
		}

		$_fillable = $this->_fillable;
		$_guarded  = $this->_guarded;

		if ( $this->_fillable ) {
			$this->_fillable = array_diff( $this->_fillable, $attributes );

			// If the diff removes all fillable attributes we need to use _guarded.
			if ( ! $this->_fillable ) {
				$this->_guarded = $attributes;
			}
		} else {
			$this->_guarded = array_unique( array_merge( $this->_guarded, $attributes ) );
		}

		$callback( $this );

		$this->_fillable = $_fillable;
		$this->_guarded  = $_guarded;

		static::$_unguarded = $unguarded;
	}
public function with_guarded( $attribute, $callback ) {

		if ( is_array( $attribute ) ) {
			$attributes = $attribute;
		} else {
			$attributes = func_get_args();
			$callback   = array_pop( $attributes );
		}

		$unguarded = static::$_unguarded;

		if ( $unguarded ) {
			static::$_unguarded = false;
		}

		$_fillable = $this->_fillable;
		$_guarded  = $this->_guarded;

		if ( $this->_fillable ) {
			$this->_fillable = array_diff( $this->_fillable, $attributes );

			// If the diff removes all fillable attributes we need to use _guarded.
			if ( ! $this->_fillable ) {
				$this->_guarded = $attributes;
			}
		} else {
			$this->_guarded = array_unique( array_merge( $this->_guarded, $attributes ) );
		}

		$callback( $this );

		$this->_fillable = $_fillable;
		$this->_guarded  = $_guarded;

		static::$_unguarded = $unguarded;
	}
public function with_guarded ( $ attribute , $ callback ) { if ( is_array ( $ attribute ) ) { $ attributes = $ attribute ; } else { $ attributes = func_get_args ( ) ; $ callback = array_pop ( $ attributes ) ; } $ unguarded = static :: $ _unguarded ; if ( $ unguarded ) { static :: $ _unguarded = false ; } $ _fillable = $ this -> _fillable ; $ _guarded = $ this -> _guarded ; if ( $ this -> _fillable ) { $ this -> _fillable = array_diff ( $ this -> _fillable , $ attributes ) ; // If the diff removes all fillable attributes we need to use _guarded. if ( ! $ this -> _fillable ) { $ this -> _guarded = $ attributes ; } } else { $ this -> _guarded = array_unique ( array_merge ( $ this -> _guarded , $ attributes ) ) ; } $ callback ( $ this ) ; $ this -> _fillable = $ _fillable ; $ this -> _guarded = $ _guarded ; static :: $ _unguarded = $ unguarded ; }
Make a function call with a given attribute guarded.

@since 2.1.0

@param string|array $attribute,...
@param callable     $callback
Make a function call with a given attribute guarded .