1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
| <?php
namespace App\Validators;
/**
* Replace the :date attribute value in a validation error message with the
* locale-specific date format.
*
* Registered in AppServiceProvider.
*
* @author Christian Weiske <weiske@mogic.com>
*/
class LocalDateFormatReplacer
{
/**
* Replace the :date attribute value with the local date format.
*
* @param string $message Message with ":date" placeholder
* @param string $attribute Name of attribute (e.g. "contract_start")
* @param string $rule Name of the rule (e.g. "before_or_equals")
* @param array $parameters Attributes to dipsplay. Key 0 is the date.
*
* @return string Final message with replaced :date
*/
function replace($message, $attribute, $rule, $parameters)
{
$parameters[0] = format_local_date($parameters[0]);
return str_replace(':date', $parameters[0], $message);
}
}
?>
|