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
32
33
34
35
36
37
38
39
| <?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.
* @param object $validator Validator instance
*
* @return string Final message with replaced :date
*/
function replace($message, $attribute, $rule, $parameters, $validator)
{
if (strtotime($parameters[0]) === false) {
//a label, not a time string
$date = $validator->getDisplayableAttribute($parameters[0]);
} else {
$date = reos_date($parameters[0]);
}
return str_replace(':date', $date, $message);
}
}
?>
|