1 | <?php |
||
2 | |||
3 | namespace ProtoneMedia\LaravelFormComponents\Components; |
||
4 | |||
5 | trait HandlesDefaultAndOldValue |
||
6 | { |
||
7 | use HandlesBoundValues; |
||
8 | |||
9 | private function setValue( |
||
10 | string $name, |
||
11 | $bind = null, |
||
12 | $default = null, |
||
13 | $language = null |
||
14 | ) { |
||
15 | if ($this->isWired()) { |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
16 | return; |
||
17 | } |
||
18 | |||
19 | $inputName = static::convertBracketsToDots($name); |
||
20 | |||
21 | if (!$language) { |
||
22 | $boundValue = $this->getBoundValue($bind, $name); |
||
23 | |||
24 | $default = is_null($boundValue) ? $default : $boundValue; |
||
25 | |||
26 | return $this->value = old($inputName, $default); |
||
0 ignored issues
–
show
|
|||
27 | } |
||
28 | |||
29 | if ($bind !== false) { |
||
30 | $bind = $bind ?: $this->getBoundTarget(); |
||
31 | } |
||
32 | |||
33 | if ($bind) { |
||
34 | $default = $bind->getTranslation($name, $language, false) ?: $default; |
||
35 | } |
||
36 | |||
37 | $this->value = old("{$inputName}.{$language}", $default); |
||
38 | } |
||
39 | } |
||
40 |