Given a specific attribute with parameters, this will resolve it while first resolving any dependent attributes
that first need to be resolved.

@param $attribute
@param array $parameters
4720
protected function resolveParametersForAttribute($attribute, array $parameters)
    {
        $children = $this->getDependentAttributes($parameters);

        if (!empty($children)) {
            foreach ($children as $child) {
                $this->resolveParametersForAttribute($child, $this->requirements[$child]);
            }
        }

        $this->doResolveParametersForAttribute($attribute, $parameters);
        $remainingParameters = self::getParametersInValue($this->attributes[$attribute]);

        // A second pass may be required for attributes it depended on that contained parameters not based on attributes
        if (!empty($remainingParameters)) {
            $this->doResolveParametersForAttribute($attribute, $remainingParameters);
        }

        $this->resolvedParameters[] = $attribute;
    }
1055012
protected function addFailure( $attribute, $rule, array $parameters )
	{
		$this->addError( $attribute, $rule, $parameters );

		$this->failedRules[ $attribute ][ $rule ] = $parameters;
	}
1073461
public function validateBefore($attribute, $value, $parameters)
    {
        $this->requireParameterCount(1, $parameters, 'before');

        return $this->compareDates($attribute, $value, $parameters, '<');
    }
1171997
public function save(array $attributes = null)
    {
        if ($attributes !== null) {
            $this->fillProperties($attributes, false);
        }

        $this->doQuery($this->saveQuery($attributes));
    }
112732
protected function getDependentAttributes($parameters)
    {
        $dependencies = [];

        foreach ($parameters as $parameter) {
            if (isset($this->requirements[$parameter]) && !in_array($parameter, $this->resolvedParameters)) {
                $dependencies[] = $parameter;
            }
        }

        return $dependencies;
    }
424218
public function setAttributeArray(array $attributes = null)
    {
        if (!is_array($attributes) || empty($attributes)) {
            return;
        }

        foreach ($attributes as $name => $value) {
            $this->setAttribute($name, $value);
        }
    }
824244
protected function validateRequiredIf($attribute, $value, $parameters)
	{
		if ($parameters[1] == array_get($this->data, $parameters[0]))
		{
			return $this->validateRequired($attribute, $value);
		}

		return true;
	}
824666
public function fill(array $attributes = [])
    {
        $this->raw = $attributes;

        $excludes = config("api.excludes");

        foreach ($attributes as $key => $attribute) {
            // Guarded attributes should be removed
            if (in_array($key, $excludes)) {
                unset($attributes[$key]);
            }
            else if (method_exists($this, $key) && ((is_array($attribute) || is_null($attribute)))) {
                // Its a relation
                $this->relationAttributes[$key] = $attribute;

                // For belongs to relation, while filling, we need to set relation key.
                $relation = call_user_func([$this, $key]);

                if ($relation instanceof BelongsTo) {
                    $primaryKey = $relation->getRelated()->getKeyName();

                    if ($attribute !== null) {
                        // If key value is not set in request, we create new object
                        if (!isset($attribute[$primaryKey])) {
                            throw new RelatedResourceNotFoundException('Resource for relation "' . $key . '" not found');
                        }
                        else {
                            $model = $relation->getRelated()->find($attribute[$primaryKey]);

                            if (!$model) {
                                // Resource not found
                                throw new ResourceNotFoundException();
                            }
                        }
                    }

                    $relationKey = $relation->getForeignKey();

                    $this->setAttribute($relationKey, ($attribute === null) ? null : $model->getKey());
                }

                unset($attributes[$key]);
            }
        }

        return parent::fill($attributes);
    }
695137
protected function validateDistinct( $attribute, $value, $parameters )
	{
		$attributeName = $this->getPrimaryAttribute( $attribute );

		$explicitPath = $this->getLeadingExplicitAttributePath( $attributeName );

		$attributeData = $this->extractDataFromPath( $explicitPath );

		$data = Arr::where( Arr::dot( $attributeData ), function ( $key ) use ( $attribute, $attributeName )
		{
			return $key != $attribute && Str::is( $attributeName, $key );
		} );

		return !in_array( $value, array_values( $data ) );
	}
220644
protected function validate( $attribute, $rule )
	{
		list( $rule, $parameters ) = $this->parseRule( $rule );

		if ( $rule == '' )
		{
			return;
		}

		// First we will get the correct keys for the given attribute in case the field is nested in
		// an array. Then we determine if the given rule accepts other field names as parameters.
		// If so, we will replace any asterisks found in the parameters with the correct keys.
		if ( ( $keys = $this->getExplicitKeys( $attribute ) ) && $this->dependsOnOtherFields( $rule ) )
		{
			$parameters = $this->replaceAsterisksInParameters( $parameters, $keys );
		}

		// We will get the value for the given attribute from the array of data and then
		// verify that the attribute is indeed validatable. Unless the rule implies
		// that the attribute is required, rules are not run for missing values.
		$value = $this->getValue( $attribute );

		$validatable = $this->isValidatable( $rule, $attribute, $value );

		$method = "validate{$rule}";

		if ( $validatable && !$this->$method( $attribute, $value, $parameters, $this ) )
		{
			$this->addFailure( $attribute, $rule, $parameters );
		}
	}
942761
protected function addError($attribute, $rule, $parameters)
    {
        $message = $this->getMessage($attribute, $rule);

        $message = $this->doReplacements($message, $attribute, $rule, $parameters);

        $this->messages->add($attribute, $message);
    }
1116222
public function setAttributes( $attributes = array() )
	{
		if( !empty( $attributes['class'] ) && is_string( $attributes['class'] ) )
			$attributes['class']	= explode( ' ', $attributes['class'] );
		$this->addAttributes( $attributes );
	}
674739
public function addParameter($attribute)
    {
        $attribute = array_change_key_case($attribute, CASE_LOWER);
        $this->parameters[$attribute['name']] = $attribute['value'];
    }
947566
public function validateAfter($attribute, $value, $parameters)
    {
        $this->requireParameterCount(1, $parameters, 'after');

        return $this->compareDates($attribute, $value, $parameters, '>');
    }
1263231
public function validateArrayWithAllOrNone($attribute, $value, $parameters)
    {
        $missing = 0;

        foreach ($parameters as $key) {
            if (!isset($value[$key])) {
                ++$missing;
            }
        }

        return $missing === count($parameters) || $missing === 0;
    }
590707
public function resolve($resource, $attribute = null)
    {
        $attribute = $attribute ?? $this->attribute;

        $value = $resource->{$attribute};

        $this->value = is_object($value) || is_array($value) ? $value : json_decode($value);

        $this->fields->whereInstanceOf(Date::class)->each(function ($dateField) {
            $dateField->resolveCallback = function ($value) {
                return \Carbon\Carbon::parse($value)->format('Y-m-d');
            };
        });

        $this->fields->whereInstanceOf(Resolvable::class)->each->resolve($this->value);

        $this->withMeta(['fields' => $this->fields]);

        parent::resolve($resource, $attribute);
    }
780821
public function normalizeTags($attribute, $params)
    {
        $this->tags = Tag::array2String(array_unique(Tag::string2Array($this->tags)));
    }