/** * Get the displayable name of the attribute. * * @param string $attribute * @return string */ protected function getAttribute($attribute) { // Get the second to last segment in singular form for arrays. // For example, `group.names.0` becomes `name`. if (str_contains($attribute, '.')) { $segments = explode('.', $attribute); $attribute = str_singular($segments[count($segments) - 2]); } return parent::getAttribute($attribute); }