protected function getMessage($attribute, $rule)
{
$lowerRule = snake_case($rule);
$inlineMessage = $this->getInlineMessage($attribute, $lowerRule);
// First we will retrieve the custom message for the validation rule if one
// exists. If a custom validation message is being used we'll return the
// custom message, otherwise we'll keep searching for a valid message.
if (!is_null($inlineMessage)) {
return $inlineMessage;
}
$customKey = "validation.custom.{$attribute}.{$lowerRule}";
$customMessage = $this->translator->trans($customKey);
// First we check for a custom defined validation message for the attribute
// and rule. This allows the developer to specify specific messages for
// only some attributes and rules that need to get specially formed.
if ($customMessage !== $customKey) {
return $customMessage;
} elseif (in_array($rule, $this->sizeRules, true)) {
return $this->getSizeMessage($attribute, $rule);
}
// Finally, if no developer specified messages have been set, and no other
// special messages apply for this rule, we will just pull the default
// messages out of the translator service for this validation rule.
$key = "validation.{$lowerRule}";
if ($key !== ($value = $this->translator->trans($key))) {
return $value;
}
return $this->getInlineMessage($attribute, $lowerRule, $this->fallbackMessages) ?: $key;
}