1 | <?php |
||
9 | trait HasTranslations |
||
10 | { |
||
11 | /** |
||
12 | * @param string $key |
||
13 | * |
||
14 | * @return mixed |
||
15 | */ |
||
16 | public function getAttributeValue($key) |
||
24 | |||
25 | /** |
||
26 | * @param string $key |
||
27 | * @param string $locale |
||
28 | * |
||
29 | * @return mixed |
||
30 | */ |
||
31 | public function translate(string $key, string $locale = '') |
||
35 | |||
36 | /*** |
||
37 | * @param string $key |
||
38 | * @param string $locale |
||
39 | * |
||
40 | * @return mixed |
||
41 | */ |
||
42 | public function getTranslation(string $key, string $locale) |
||
56 | |||
57 | public function getTranslations($key) : array |
||
63 | |||
64 | /** |
||
65 | * @param string $key |
||
66 | * @param string $locale |
||
67 | * @param $value |
||
68 | * |
||
69 | * @return $this |
||
70 | */ |
||
71 | public function setTranslation(string $key, string $locale, $value) |
||
92 | |||
93 | /** |
||
94 | * @param string $key |
||
95 | * @param array $translations |
||
96 | * |
||
97 | * @return $this |
||
98 | */ |
||
99 | public function setTranslations(string $key, array $translations) |
||
109 | |||
110 | /** |
||
111 | * @param string $key |
||
112 | * @param string $locale |
||
113 | * |
||
114 | * @return $this |
||
115 | */ |
||
116 | public function forgetTranslation(string $key, string $locale) |
||
126 | |||
127 | public function getTranslatedLocales(string $key) : array |
||
131 | |||
132 | protected function isTranslatableAttribute(string $key) : bool |
||
136 | |||
137 | protected function guardAgainstUntranslatableAttribute(string $key) |
||
143 | |||
144 | protected function normalizeLocale(string $key, string $locale) : string |
||
156 | |||
157 | public function getTranslatableAttributes() : array |
||
163 | |||
164 | public function getCasts() : array |
||
171 | |||
172 | /** |
||
173 | * Handle dynamic method calls into the model (hook for builder only). |
||
174 | * |
||
175 | * @param string $method |
||
176 | * @param array $parameters |
||
177 | * @return mixed |
||
178 | */ |
||
179 | public function __call($method, $parameters) |
||
209 | } |
||
210 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: