@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | // TODO: Cleanup (avoid repetition) |
147 | 147 | // Try to create new Instance of Handler and return it |
148 | 148 | try { |
149 | - $oHandler = new $oHandler($locale); |
|
149 | + $oHandler = new $oHandler($locale); |
|
150 | 150 | } |
151 | 151 | catch (TranslationCacheNotFound $exception) { |
152 | 152 | // Log error and fallback procedure |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | private function replaceParameter ($translation, $parameters) { |
232 | 232 | |
233 | 233 | // Go through each specified Parameter and replace its placeholder "{$key}" |
234 | - foreach ($parameters as $key => $parameter) { |
|
234 | + foreach ($parameters as $key => $parameter) { |
|
235 | 235 | // TODO: Make Prefix and Suffix configurable |
236 | 236 | // If the string (e.g "{name}") is not specified within the "parameters" array it won't be replaced! |
237 | 237 | $translation = str_replace("{".$key."}", $parameter, $translation); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @throws \Exception |
60 | 60 | * TODO: Make function Parameters interchangeable |
61 | 61 | */ |
62 | - public function translate($identifier , $parameters = null, $locale = '') { |
|
62 | + public function translate($identifier, $parameters = null, $locale = '') { |
|
63 | 63 | |
64 | 64 | // Validate the locale given as parameter or take the saved locale |
65 | 65 | if ($locale !== '' || $this->locale === '') { |
@@ -181,12 +181,12 @@ discard block |
||
181 | 181 | */ |
182 | 182 | public function addMissingIdentifier($identifier, $parameters, $group) { |
183 | 183 | |
184 | - if(! $this->hasIdentifier($identifier)) { |
|
184 | + if (!$this->hasIdentifier($identifier)) { |
|
185 | 185 | |
186 | 186 | // Save only the keys from the parameter array |
187 | 187 | $keys = []; |
188 | 188 | if (is_array($parameters)) { |
189 | - foreach($parameters as $key => $value) { |
|
189 | + foreach ($parameters as $key => $value) { |
|
190 | 190 | $keys[] = $key; |
191 | 191 | } |
192 | 192 | } |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | * @param $parameters |
229 | 229 | * @return string |
230 | 230 | */ |
231 | - private function replaceParameter ($translation, $parameters) { |
|
231 | + private function replaceParameter($translation, $parameters) { |
|
232 | 232 | |
233 | 233 | // Go through each specified Parameter and replace its placeholder "{$key}" |
234 | 234 | foreach ($parameters as $key => $parameter) { |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @return string |
250 | 250 | * @throws \Exception |
251 | 251 | */ |
252 | - private function returnMissingTranslation ($identifier, $locale) { |
|
252 | + private function returnMissingTranslation($identifier, $locale) { |
|
253 | 253 | |
254 | 254 | // Return identifier and locale for easier debug |
255 | 255 | if (config('app.env') !== 'production') { |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | } |
280 | 280 | |
281 | 281 | // Fallback if empty locale was given (should be handled in middleware) |
282 | - if ($locale == ''){ |
|
282 | + if ($locale == '') { |
|
283 | 283 | if (session()->get('locale') != '') { |
284 | 284 | $locale = session()->get('locale'); |
285 | 285 | } |
@@ -289,19 +289,19 @@ discard block |
||
289 | 289 | } |
290 | 290 | |
291 | 291 | // If the given locale is not defined as valid, try to get a fallback locale |
292 | - if (!in_array($locale, $avail_locales)){ |
|
292 | + if (!in_array($locale, $avail_locales)) { |
|
293 | 293 | |
294 | 294 | $found_locales = []; |
295 | 295 | |
296 | 296 | // Find any available locale which contains the locale as substring |
297 | 297 | foreach ($avail_locales as $avail_locale) { |
298 | - if (strpos($avail_locale, $locale) !== false){ |
|
298 | + if (strpos($avail_locale, $locale) !== false) { |
|
299 | 299 | $found_locales[] = $avail_locale; |
300 | 300 | } |
301 | 301 | } |
302 | 302 | |
303 | 303 | // Check if default locale is inside the found locales. If it was, use it! |
304 | - if (in_array($default_locale, $found_locales)){ |
|
304 | + if (in_array($default_locale, $found_locales)) { |
|
305 | 305 | Log::warning('Locale "'.$locale.'" was not found! Falling back to default locale "'.$default_locale.'"'); |
306 | 306 | $locale = $default_locale; |
307 | 307 | } |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | * @return array|mixed |
325 | 325 | */ |
326 | 326 | public function getAllTranslations($locale, $group) { |
327 | - if(!isset($this->aHandler[$locale])) { |
|
327 | + if (!isset($this->aHandler[$locale])) { |
|
328 | 328 | $this->aHandler[$locale] = $this->createHandler($locale); |
329 | 329 | } |
330 | 330 |
@@ -124,14 +124,12 @@ discard block |
||
124 | 124 | // Check if the class from the config exists and implements HandlerInterface |
125 | 125 | if (class_exists($handler_class) && is_a($handler_class, 'Hokan22\LaravelTranslator\Handler\HandlerInterface', TRUE)) { |
126 | 126 | $oHandler = $handler_class; |
127 | - } |
|
128 | - elseif (!class_exists($handler_class)) { |
|
127 | + } elseif (!class_exists($handler_class)) { |
|
129 | 128 | // If one of the previous check fails check if the class does not exists and set message accordingly |
130 | 129 | // As it could either be the class does not exist or does not implement HandlerInterface |
131 | 130 | // check only the shorter statement to improve readability |
132 | 131 | $message = "Handler '".$handler_class."' not found."; |
133 | - } |
|
134 | - else { |
|
132 | + } else { |
|
135 | 133 | // If the class exists but the class does not implement HandlerInterface set the message accordingly |
136 | 134 | $message = "Handler '".$handler_class."' does not implement HandlerInterface."; |
137 | 135 | } |
@@ -147,8 +145,7 @@ discard block |
||
147 | 145 | // Try to create new Instance of Handler and return it |
148 | 146 | try { |
149 | 147 | $oHandler = new $oHandler($locale); |
150 | - } |
|
151 | - catch (TranslationCacheNotFound $exception) { |
|
148 | + } catch (TranslationCacheNotFound $exception) { |
|
152 | 149 | // Log error and fallback procedure |
153 | 150 | Log::error($exception); |
154 | 151 | Log::warning('Falling back to DatabaseHandler'); |
@@ -207,8 +204,7 @@ discard block |
||
207 | 204 | |
208 | 205 | // Print notice about creation to laravel log |
209 | 206 | Log::notice('The translation string "'.$identifier.'" will be written to the Database'); |
210 | - } |
|
211 | - else { |
|
207 | + } else { |
|
212 | 208 | Log::warning('The translation string "'.$identifier.'" is already in the Database!'); |
213 | 209 | } |
214 | 210 | } |
@@ -279,29 +275,28 @@ discard block |
||
279 | 275 | } |
280 | 276 | |
281 | 277 | // Fallback if empty locale was given (should be handled in middleware) |
282 | - if ($locale == ''){ |
|
278 | + if ($locale == '') { |
|
283 | 279 | if (session()->get('locale') != '') { |
284 | 280 | $locale = session()->get('locale'); |
285 | - } |
|
286 | - else { |
|
281 | + } else { |
|
287 | 282 | return $default_locale; |
288 | 283 | } |
289 | 284 | } |
290 | 285 | |
291 | 286 | // If the given locale is not defined as valid, try to get a fallback locale |
292 | - if (!in_array($locale, $avail_locales)){ |
|
287 | + if (!in_array($locale, $avail_locales)) { |
|
293 | 288 | |
294 | 289 | $found_locales = []; |
295 | 290 | |
296 | 291 | // Find any available locale which contains the locale as substring |
297 | 292 | foreach ($avail_locales as $avail_locale) { |
298 | - if (strpos($avail_locale, $locale) !== false){ |
|
293 | + if (strpos($avail_locale, $locale) !== false) { |
|
299 | 294 | $found_locales[] = $avail_locale; |
300 | 295 | } |
301 | 296 | } |
302 | 297 | |
303 | 298 | // Check if default locale is inside the found locales. If it was, use it! |
304 | - if (in_array($default_locale, $found_locales)){ |
|
299 | + if (in_array($default_locale, $found_locales)) { |
|
305 | 300 | Log::warning('Locale "'.$locale.'" was not found! Falling back to default locale "'.$default_locale.'"'); |
306 | 301 | $locale = $default_locale; |
307 | 302 | } |
@@ -309,8 +304,7 @@ discard block |
||
309 | 304 | elseif (count($found_locales, 0) >= 1) { |
310 | 305 | Log::warning('Locale "'.$locale.'" was not found! Falling back to similar locale "'.$found_locales[0].'"'); |
311 | 306 | $locale = $found_locales[0]; |
312 | - } |
|
313 | - else { |
|
307 | + } else { |
|
314 | 308 | throw new NotFoundResourceException("Locale '".$locale."' was not found in available locales"); |
315 | 309 | } |
316 | 310 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | |
24 | 24 | $locale = TranslatorFacade::validateLocale($locale); |
25 | 25 | |
26 | - if(Session::has('locale') == false){ |
|
26 | + if (Session::has('locale') == false) { |
|
27 | 27 | Session::put('locale', $locale); |
28 | 28 | Session::save(); |
29 | 29 | } |
@@ -16,21 +16,19 @@ |
||
16 | 16 | * @param \Closure $next |
17 | 17 | * @return mixed |
18 | 18 | */ |
19 | - public function handle($request, Closure $next) |
|
20 | - { |
|
19 | + public function handle($request, Closure $next) { |
|
21 | 20 | if (Session::has('locale') || auth()->check()) { |
22 | 21 | $locale = Session::has('locale') ? session()->get('locale') : auth()->user()->language; |
23 | 22 | |
24 | 23 | $locale = TranslatorFacade::validateLocale($locale); |
25 | 24 | |
26 | - if(Session::has('locale') == false){ |
|
25 | + if(Session::has('locale') == false) { |
|
27 | 26 | Session::put('locale', $locale); |
28 | 27 | Session::save(); |
29 | 28 | } |
30 | 29 | |
31 | 30 | app()->setLocale($locale); |
32 | - } |
|
33 | - else { |
|
31 | + } else { |
|
34 | 32 | // TODO: Validate Browser locale string (https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4) |
35 | 33 | |
36 | 34 | Session::put('locale', TranslatorFacade::getConfigValue('default_locale')); |
@@ -61,7 +61,7 @@ |
||
61 | 61 | $translations = new TranslationIdentifier(); |
62 | 62 | $translations = $translations->leftJoin('translations', function ($join) { |
63 | 63 | $join->on( 'translation_identifiers.id', '=', 'translations.translation_identifier_id') |
64 | - ->where('locale', $this->locale); |
|
64 | + ->where('locale', $this->locale); |
|
65 | 65 | })->get(); |
66 | 66 | |
67 | 67 |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function getTranslation($identifier, $group) { |
44 | 44 | |
45 | - if(isset($this->translations[$identifier])) { |
|
45 | + if (isset($this->translations[$identifier])) { |
|
46 | 46 | if ($this->translations[$identifier]->translation == null) { |
47 | 47 | throw new TranslationNotFoundException("The translation for identifier '".$identifier."' and locale '".$this->locale."' could not be found"); |
48 | 48 | } |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function refreshCache() { |
60 | 60 | // Get all Texts with translations for the given locale |
61 | - $translations = new TranslationIdentifier(); |
|
62 | - $translations = $translations->leftJoin('translations', function ($join) { |
|
63 | - $join->on( 'translation_identifiers.id', '=', 'translations.translation_identifier_id') |
|
61 | + $translations = new TranslationIdentifier(); |
|
62 | + $translations = $translations->leftJoin('translations', function($join) { |
|
63 | + $join->on('translation_identifiers.id', '=', 'translations.translation_identifier_id') |
|
64 | 64 | ->where('locale', $this->locale); |
65 | 65 | })->get(); |
66 | 66 |
@@ -47,8 +47,7 @@ discard block |
||
47 | 47 | throw new TranslationNotFoundException("The translation for identifier '".$identifier."' and locale '".$this->locale."' could not be found"); |
48 | 48 | } |
49 | 49 | return $this->translations[$identifier]->translation; |
50 | - } |
|
51 | - else { |
|
50 | + } else { |
|
52 | 51 | throw new NotFoundResourceException("The translation identifier '".$identifier."' could not be found"); |
53 | 52 | } |
54 | 53 | } |
@@ -74,8 +73,7 @@ discard block |
||
74 | 73 | * @param $group |
75 | 74 | * @return mixed |
76 | 75 | */ |
77 | - public function getAllTranslations($group = 'default') |
|
78 | - { |
|
76 | + public function getAllTranslations($group = 'default') { |
|
79 | 77 | $return = []; |
80 | 78 | foreach (collect($this->translations)->where('group', $group) as $key => $translation) { |
81 | 79 | if ($translation->translation == null) { |
@@ -63,7 +63,7 @@ |
||
63 | 63 | |
64 | 64 | // If a Group is defined just get the translations from that group |
65 | 65 | try { |
66 | - $trans_identifier = json_decode(file_get_contents($locale_dir.'/'.$group.'.json'), true); |
|
66 | + $trans_identifier = json_decode(file_get_contents($locale_dir.'/'.$group.'.json'), true); |
|
67 | 67 | } |
68 | 68 | catch (\ErrorException $e) { |
69 | 69 | throw new TranslationCacheNotFound("The Translation cache file '".$locale_dir.'/'.$group.'.json'."' could not be found!"); |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @throws TranslationCacheNotFound |
21 | 21 | */ |
22 | 22 | public function __construct($locale) { |
23 | - $this->locale = $locale; |
|
23 | + $this->locale = $locale; |
|
24 | 24 | |
25 | 25 | $this->refreshCache(); |
26 | 26 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | // NOTE: This should never trigger the addition of the identifier to the database, |
45 | 45 | // because the cache will not be updated automatically. |
46 | 46 | // So not finding the same identifier twice in the cache, will result in an error. |
47 | - if(isset($this->translations[$group][$identifier])) { |
|
47 | + if (isset($this->translations[$group][$identifier])) { |
|
48 | 48 | return $this->translations[$group][$identifier]; |
49 | 49 | } |
50 | 50 | else { |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function getAllTranslations($group) |
82 | 82 | { |
83 | - if(!isset($this->translations[$group])) { |
|
83 | + if (!isset($this->translations[$group])) { |
|
84 | 84 | $this->refreshCache($group); |
85 | 85 | } |
86 | 86 | return $this->translations[$group]; |
@@ -8,7 +8,8 @@ discard block |
||
8 | 8 | * Class LocaleHandler |
9 | 9 | * @package Hokan22\LaravelTranslator\ |
10 | 10 | */ |
11 | -class CacheJSONHandler implements HandlerInterface { |
|
11 | +class CacheJSONHandler implements HandlerInterface |
|
12 | +{ |
|
12 | 13 | /** @var string The locale to translate to */ |
13 | 14 | private $locale; |
14 | 15 | /** @var array|array[] Array with the identifiers as keys and the Texts object as value */ |
@@ -46,8 +47,7 @@ discard block |
||
46 | 47 | // So not finding the same identifier twice in the cache, will result in an error. |
47 | 48 | if(isset($this->translations[$group][$identifier])) { |
48 | 49 | return $this->translations[$group][$identifier]; |
49 | - } |
|
50 | - else { |
|
50 | + } else { |
|
51 | 51 | throw new TranslationNotInCacheException("The translation identifier '".$identifier."' could not be found in Cache"); |
52 | 52 | } |
53 | 53 | } |
@@ -64,8 +64,7 @@ discard block |
||
64 | 64 | // If a Group is defined just get the translations from that group |
65 | 65 | try { |
66 | 66 | $trans_identifier = json_decode(file_get_contents($locale_dir.'/'.$group.'.json'), true); |
67 | - } |
|
68 | - catch (\ErrorException $e) { |
|
67 | + } catch (\ErrorException $e) { |
|
69 | 68 | throw new TranslationCacheNotFound("The Translation cache file '".$locale_dir.'/'.$group.'.json'."' could not be found!"); |
70 | 69 | } |
71 | 70 | |
@@ -78,8 +77,7 @@ discard block |
||
78 | 77 | * @return array|mixed |
79 | 78 | * @throws TranslationCacheNotFound |
80 | 79 | */ |
81 | - public function getAllTranslations($group) |
|
82 | - { |
|
80 | + public function getAllTranslations($group) { |
|
83 | 81 | if(!isset($this->translations[$group])) { |
84 | 82 | $this->refreshCache($group); |
85 | 83 | } |
@@ -11,7 +11,9 @@ discard block |
||
11 | 11 | * Class TranslationNotFoundException |
12 | 12 | * @package Hokan22\LaravelTranslator\Handler |
13 | 13 | */ |
14 | -class TranslationNotFoundException extends \Exception {} |
|
14 | +class TranslationNotFoundException extends \Exception |
|
15 | +{ |
|
16 | +} |
|
15 | 17 | |
16 | 18 | /** |
17 | 19 | * Custom Exception to distinguish if the Translation Identifier was not found in Cache but could be in DB |
@@ -19,7 +21,9 @@ discard block |
||
19 | 21 | * Class TranslationNotInCacheException |
20 | 22 | * @package Hokan22\LaravelTranslator\Handler |
21 | 23 | */ |
22 | -class TranslationNotInCacheException extends TranslationNotFoundException {} |
|
24 | +class TranslationNotInCacheException extends TranslationNotFoundException |
|
25 | +{ |
|
26 | +} |
|
23 | 27 | |
24 | 28 | /** |
25 | 29 | * Custom Exception thrown when a cache file could not be found |
@@ -27,7 +31,9 @@ discard block |
||
27 | 31 | * Class TranslationCacheNotFound |
28 | 32 | * @package Hokan22\LaravelTranslator\Handler |
29 | 33 | */ |
30 | -class TranslationCacheNotFound extends \Exception {} |
|
34 | +class TranslationCacheNotFound extends \Exception |
|
35 | +{ |
|
36 | +} |
|
31 | 37 | |
32 | 38 | /** |
33 | 39 | * Interface HandlerInterface |
@@ -33,12 +33,12 @@ |
||
33 | 33 | }); |
34 | 34 | } |
35 | 35 | |
36 | - /** |
|
37 | - * Strip the parentheses from the given expression. |
|
38 | - * |
|
39 | - * @param string $expression |
|
40 | - * @return string |
|
41 | - */ |
|
36 | + /** |
|
37 | + * Strip the parentheses from the given expression. |
|
38 | + * |
|
39 | + * @param string $expression |
|
40 | + * @return string |
|
41 | + */ |
|
42 | 42 | public function stripParentheses($expression) |
43 | 43 | { |
44 | 44 | if (Str::startsWith($expression, '(')) { |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | */ |
17 | 17 | public function boot() |
18 | 18 | { |
19 | - Blade::directive('translate', function ($expression) { |
|
19 | + Blade::directive('translate', function($expression) { |
|
20 | 20 | |
21 | 21 | $expression = $this->stripParentheses($expression); |
22 | 22 | |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | return "<?php echo Hokan22\\LaravelTranslator\\TranslatorFacade::translate({$expression}); ?>"; |
25 | 25 | }); |
26 | 26 | |
27 | - Blade::directive('t', function ($expression) { |
|
27 | + Blade::directive('t', function($expression) { |
|
28 | 28 | |
29 | 29 | $expression = $this->stripParentheses($expression); |
30 | 30 |
@@ -14,8 +14,7 @@ discard block |
||
14 | 14 | * |
15 | 15 | * @return void |
16 | 16 | */ |
17 | - public function boot() |
|
18 | - { |
|
17 | + public function boot() { |
|
19 | 18 | Blade::directive('translate', function ($expression) { |
20 | 19 | |
21 | 20 | $expression = $this->stripParentheses($expression); |
@@ -39,8 +38,7 @@ discard block |
||
39 | 38 | * @param string $expression |
40 | 39 | * @return string |
41 | 40 | */ |
42 | - public function stripParentheses($expression) |
|
43 | - { |
|
41 | + public function stripParentheses($expression) { |
|
44 | 42 | if (Str::startsWith($expression, '(')) { |
45 | 43 | $expression = substr($expression, 1, -1); |
46 | 44 | } |
@@ -53,7 +51,6 @@ discard block |
||
53 | 51 | * |
54 | 52 | * @return void |
55 | 53 | */ |
56 | - public function register() |
|
57 | - { |
|
54 | + public function register() { |
|
58 | 55 | } |
59 | 56 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | { |
18 | 18 | $this->mergeConfigFrom(__DIR__.'/../config/translator.php', 'translator'); |
19 | 19 | |
20 | - $this->app->singleton('Translator', function () { |
|
20 | + $this->app->singleton('Translator', function() { |
|
21 | 21 | return new Translator(); |
22 | 22 | }); |
23 | 23 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function boot() { |
31 | 31 | $this->publishes([ |
32 | - __DIR__ . '/../config/translator.php' => config_path('translator.php'), |
|
32 | + __DIR__.'/../config/translator.php' => config_path('translator.php'), |
|
33 | 33 | ], |
34 | 34 | 'config' |
35 | 35 | ); |
@@ -13,8 +13,7 @@ |
||
13 | 13 | * |
14 | 14 | * @return void |
15 | 15 | */ |
16 | - public function register() |
|
17 | - { |
|
16 | + public function register() { |
|
18 | 17 | $this->mergeConfigFrom(__DIR__.'/../config/translator.php', 'translator'); |
19 | 18 | |
20 | 19 | $this->app->singleton('Translator', function () { |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (! Hokan22\LaravelTranslator\TranslatorFacade::getConfigValue('custom_routes')) { |
|
3 | +if (!Hokan22\LaravelTranslator\TranslatorFacade::getConfigValue('custom_routes')) { |
|
4 | 4 | |
5 | - Route::group(['prefix' => 'translator'], function () { |
|
5 | + Route::group(['prefix' => 'translator'], function() { |
|
6 | 6 | |
7 | 7 | Route::get('/test', 'Hokan22\LaravelTranslator\Controllers\TranslatorAdminController@test')->name('translator.test'); |
8 | 8 | |
9 | - Route::group(['prefix' => 'admin'], function () { |
|
9 | + Route::group(['prefix' => 'admin'], function() { |
|
10 | 10 | |
11 | 11 | Route::get('/', 'Hokan22\LaravelTranslator\Controllers\TranslatorAdminController@index')->name('translator.admin'); |
12 | 12 | Route::post('/', 'Hokan22\LaravelTranslator\Controllers\TranslatorAdminController@postIdentifier')->name('translator.post.admin'); |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
22 | 22 | */ |
23 | - public function index () { |
|
23 | + public function index() { |
|
24 | 24 | |
25 | 25 | $locale = Input::get('locale', ''); |
26 | 26 | $search = Input::get('search', ''); |
@@ -28,24 +28,24 @@ discard block |
||
28 | 28 | $query = TranslationIdentifier::with('translations')->orderBy('updated_at', 'DESC')->orderBy('id', 'DESC'); |
29 | 29 | |
30 | 30 | if ($locale != '') { |
31 | - $query = TranslationIdentifier::wheredoesntHave('translations', function ($query) use ($locale) { |
|
31 | + $query = TranslationIdentifier::wheredoesntHave('translations', function($query) use ($locale) { |
|
32 | 32 | $query->where('locale', 'like', $locale); |
33 | 33 | }); |
34 | 34 | } |
35 | 35 | |
36 | 36 | if ($search != '') { |
37 | - $query = TranslationIdentifier::where('identifier', 'LIKE', '%'.$search.'%') |
|
37 | + $query = TranslationIdentifier::where('identifier', 'LIKE', '%'.$search.'%') |
|
38 | 38 | ->orWhere('parameters', 'LIKE', '%'.$search.'%') |
39 | - ->orWhere('group', 'LIKE', '%'.$search.'%') |
|
40 | - ->orWhere('page_name', 'LIKE', '%'.$search.'%') |
|
41 | - ->orWhere('description','LIKE', '%'.$search.'%'); |
|
39 | + ->orWhere('group', 'LIKE', '%'.$search.'%') |
|
40 | + ->orWhere('page_name', 'LIKE', '%'.$search.'%') |
|
41 | + ->orWhere('description', 'LIKE', '%'.$search.'%'); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | $trans_identifier = $query->orderBy('updated_at', 'DESC')->orderBy('id', 'DESC')->paginate(20)->appends(Input::except('page')); |
45 | 45 | |
46 | 46 | $available_locales = TranslatorFacade::getConfigValue('available_locales'); |
47 | 47 | |
48 | - return view('translator::index',[ |
|
48 | + return view('translator::index', [ |
|
49 | 49 | 'identifier' => $trans_identifier, |
50 | 50 | 'available_locales' => $available_locales, |
51 | 51 | ]); |
@@ -55,13 +55,13 @@ discard block |
||
55 | 55 | * @param $id |
56 | 56 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
57 | 57 | */ |
58 | - public function edit ($id) { |
|
58 | + public function edit($id) { |
|
59 | 59 | |
60 | 60 | $identifier = TranslationIdentifier::findOrFail($id); |
61 | 61 | |
62 | 62 | $available_locales = TranslatorFacade::getConfigValue('available_locales'); |
63 | 63 | |
64 | - return view('translator::edit',[ |
|
64 | + return view('translator::edit', [ |
|
65 | 65 | 'identifier' => $identifier, |
66 | 66 | 'available_locales' => $available_locales, |
67 | 67 | ]); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @param Request $request |
74 | 74 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
75 | 75 | */ |
76 | - public function postEdit ($id, Request $request) { |
|
76 | + public function postEdit($id, Request $request) { |
|
77 | 77 | |
78 | 78 | TranslationIdentifier::findOrFail($id); |
79 | 79 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @param Request $request |
107 | 107 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
108 | 108 | */ |
109 | - public function postIdentifier (Request $request) { |
|
109 | + public function postIdentifier(Request $request) { |
|
110 | 110 | |
111 | 111 | /** @var TranslationIdentifier $translation_identifiers */ |
112 | 112 | $translation_identifiers = TranslationIdentifier::all()->whereIn('id', array_keys($request->all())); |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | /** |
134 | 134 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
135 | 135 | */ |
136 | - public function test () { |
|
136 | + public function test() { |
|
137 | 137 | return view('translator::test'); |
138 | 138 | } |
139 | 139 | } |
140 | 140 | \ No newline at end of file |