We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
1 | <?php |
||
7 | trait HasTranslations |
||
8 | { |
||
9 | use HasTranslations; |
||
10 | |||
11 | /** |
||
12 | * @var bool |
||
13 | */ |
||
14 | public $locale = false; |
||
15 | |||
16 | /* |
||
17 | |-------------------------------------------------------------------------- |
||
18 | | SPATIE/LARAVEL-TRANSLATABLE OVERWRITES |
||
19 | |-------------------------------------------------------------------------- |
||
20 | */ |
||
21 | |||
22 | /** |
||
23 | * Use the forced locale if present. |
||
24 | * |
||
25 | * @param string $key |
||
26 | * @return mixed |
||
27 | */ |
||
28 | public function getAttributeValue($key) |
||
38 | |||
39 | /* |
||
40 | |-------------------------------------------------------------------------- |
||
41 | | ELOQUENT OVERWRITES |
||
42 | |-------------------------------------------------------------------------- |
||
43 | */ |
||
44 | |||
45 | /** |
||
46 | * Create translated items as json. |
||
47 | * |
||
48 | * @param array $attributes |
||
49 | * @return static |
||
50 | */ |
||
51 | public static function create(array $attributes = []) |
||
70 | |||
71 | /** |
||
72 | * Update translated items as json. |
||
73 | * |
||
74 | * @param array $attributes |
||
75 | * @param array $options |
||
76 | * @return bool |
||
77 | */ |
||
78 | public function update(array $attributes = [], array $options = []) |
||
98 | |||
99 | /* |
||
100 | |-------------------------------------------------------------------------- |
||
101 | | CUSTOM METHODS |
||
102 | |-------------------------------------------------------------------------- |
||
103 | */ |
||
104 | |||
105 | /** |
||
106 | * Check if a model is translatable, by the adapter's standards. |
||
107 | * |
||
108 | * @return bool |
||
109 | */ |
||
110 | public function translationEnabledForModel() |
||
114 | |||
115 | /** |
||
116 | * Get all locales the admin is allowed to use. |
||
117 | * |
||
118 | * @return array |
||
119 | */ |
||
120 | public function getAvailableLocales() |
||
124 | |||
125 | /** |
||
126 | * Set the locale property. Used in normalizeLocale() to force the translation |
||
127 | * to a different language that the one set in app()->getLocale();. |
||
128 | * |
||
129 | * @param string |
||
130 | */ |
||
131 | public function setLocale($locale) |
||
135 | |||
136 | /** |
||
137 | * Get the locale property. Used in SpatieTranslatableSluggableService |
||
138 | * to save the slug for the appropriate language. |
||
139 | * |
||
140 | * @param string |
||
141 | */ |
||
142 | public function getLocale() |
||
150 | |||
151 | /** |
||
152 | * Magic method to get the db entries already translated in the wanted locale. |
||
153 | * |
||
154 | * @param string $method |
||
155 | * @param array $parameters |
||
156 | * @return |
||
157 | */ |
||
158 | public function __call($method, $parameters) |
||
189 | } |
||
190 |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: