1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of persian validation package |
||
5 | * |
||
6 | * (c) Farhad Zand <[email protected]> |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace Iamfarhad\Validation; |
||
13 | |||
14 | use App; |
||
15 | |||
16 | class ValidationMessages |
||
17 | { |
||
18 | /** |
||
19 | * @var mixed lang |
||
20 | */ |
||
21 | public $lang; |
||
22 | |||
23 | /** |
||
24 | * ValidationMessages constructor. |
||
25 | */ |
||
26 | public function __construct() |
||
27 | { |
||
28 | $app_lang = resource_path('lang/validation/'.App::getLocale().'.php'); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
29 | |||
30 | if (! file_exists($app_lang)) { |
||
31 | $this->lang = include $app_lang; |
||
32 | } else { |
||
33 | $this->lang = include __DIR__.'/lang/validation/'.App::getLocale().'.php'; |
||
34 | } |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * @param $message |
||
39 | * @param $attribute |
||
40 | * @param $rule |
||
41 | * @return string |
||
42 | */ |
||
43 | public function message($message, $attribute, $rule): string |
||
44 | { |
||
45 | return str_replace($message, $this->lang[$rule], $message); |
||
46 | } |
||
47 | } |
||
48 |