@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * file that was distributed with this source code. |
9 | 9 | */ |
10 | 10 | |
11 | -if (! function_exists('lang_url')) { |
|
11 | +if (!function_exists('lang_url')) { |
|
12 | 12 | /** |
13 | 13 | * Generate a url for the application. |
14 | 14 | * |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | } |
32 | 32 | } |
33 | 33 | |
34 | -if (! function_exists('lang_redirect')) { |
|
34 | +if (!function_exists('lang_redirect')) { |
|
35 | 35 | /** |
36 | 36 | * Get an instance of the redirector. |
37 | 37 | * |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | -if (! function_exists('lang_route')) { |
|
58 | +if (!function_exists('lang_route')) { |
|
59 | 59 | /** |
60 | 60 | * Get route by name |
61 | 61 | * |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | -if (! function_exists('t')) { |
|
77 | +if (!function_exists('t')) { |
|
78 | 78 | /** |
79 | 79 | * Get translated text |
80 | 80 | * |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | public function getCacheName($lang, $scope = null) |
62 | 62 | { |
63 | 63 | $key = $this->config->get('db.texts_table', 'texts') . '_' . $lang; |
64 | - if (! is_null($scope)) { |
|
64 | + if (!is_null($scope)) { |
|
65 | 65 | $key .= '_' . $scope; |
66 | 66 | } |
67 | 67 | |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | $query = $this->getDb()->table($this->getTableName()) |
81 | 81 | ->where('lang', $lang); |
82 | 82 | |
83 | - if (! is_null($scope)) { |
|
84 | - $query = $query->whereNested(function ($query) use ($scope) { |
|
83 | + if (!is_null($scope)) { |
|
84 | + $query = $query->whereNested(function($query) use ($scope) { |
|
85 | 85 | $query->where('scope', 'global'); |
86 | 86 | $query->orWhere('scope', $scope); |
87 | 87 | }); |
@@ -110,12 +110,12 @@ discard block |
||
110 | 110 | { |
111 | 111 | $query = $this->getDb()->table($this->getTableName()); |
112 | 112 | |
113 | - if (! is_null($lang)) { |
|
113 | + if (!is_null($lang)) { |
|
114 | 114 | $query = $query->where('lang', $lang); |
115 | 115 | } |
116 | 116 | |
117 | - if (! is_null($scope)) { |
|
118 | - $query = $query->whereNested(function ($query) use ($scope) { |
|
117 | + if (!is_null($scope)) { |
|
118 | + $query = $query->whereNested(function($query) use ($scope) { |
|
119 | 119 | $query->where('scope', 'global'); |
120 | 120 | $query->orWhere('scope', $scope); |
121 | 121 | }); |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | $options['scope'] = $request->scope; |
37 | 37 | } |
38 | 38 | |
39 | - $texts = Text::where(function ($q) use ($options) { |
|
39 | + $texts = Text::where(function($q) use ($options) { |
|
40 | 40 | foreach ($options as $k => $v) { |
41 | 41 | if ($k == 'keyword') { |
42 | - $q->where(function ($query) use ($v) { |
|
42 | + $q->where(function($query) use ($v) { |
|
43 | 43 | $query->where('key', 'LIKE', '%' . $v . '%')->orWhere('value', 'LIKE', '%' . $v . '%'); |
44 | 44 | }); |
45 | 45 | } else { |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | $locales = array_keys(config('multilang.locales')); |
74 | 74 | foreach ($request->texts as $lang => $items) { |
75 | - if (! in_array($lang, $locales)) { |
|
75 | + if (!in_array($lang, $locales)) { |
|
76 | 76 | //to do must set errors |
77 | 77 | continue; |
78 | 78 | } |
@@ -156,12 +156,12 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function setLocale($lang, array $texts = null) |
158 | 158 | { |
159 | - if (! $lang) { |
|
159 | + if (!$lang) { |
|
160 | 160 | throw new InvalidArgumentException('Locale is empty'); |
161 | 161 | } |
162 | 162 | $this->lang = $lang; |
163 | 163 | |
164 | - if (! is_array($texts)) { |
|
164 | + if (!is_array($texts)) { |
|
165 | 165 | $texts = $this->loadTexts($this->getLocale(), $this->scope); |
166 | 166 | } |
167 | 167 | |
@@ -207,11 +207,11 @@ discard block |
||
207 | 207 | throw new InvalidArgumentException('String key not provided'); |
208 | 208 | } |
209 | 209 | |
210 | - if (! $this->lang) { |
|
210 | + if (!$this->lang) { |
|
211 | 211 | return $key; |
212 | 212 | } |
213 | 213 | |
214 | - if (! isset($this->texts[$key])) { |
|
214 | + if (!isset($this->texts[$key])) { |
|
215 | 215 | $this->queueToSave($key); |
216 | 216 | |
217 | 217 | return $this->replaceMarkers($key, $replace); |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | */ |
269 | 269 | protected function sortReplacements(array $replace) |
270 | 270 | { |
271 | - return (new Collection($replace))->sortBy(function ($value, $key) { |
|
271 | + return (new Collection($replace))->sortBy(function($value, $key) { |
|
272 | 272 | return mb_strlen($key) * -1; |
273 | 273 | }); |
274 | 274 | } |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | if (strlen($locale) == 2) { |
292 | 292 | $locales = $this->config->get('locales', []); |
293 | 293 | |
294 | - if (! isset($locales[$locale])) { |
|
294 | + if (!isset($locales[$locale])) { |
|
295 | 295 | $segments = $request->segments(); |
296 | 296 | $segments[0] = $fallback_locale; |
297 | 297 | $url = implode('/', $segments); |
@@ -84,16 +84,16 @@ discard block |
||
84 | 84 | $this->db = $this->getDatabase(); |
85 | 85 | |
86 | 86 | $lang = $this->option('lang'); |
87 | - if (! empty($lang)) { |
|
87 | + if (!empty($lang)) { |
|
88 | 88 | $this->langs = explode(',', $lang); |
89 | 89 | } |
90 | 90 | |
91 | 91 | $scopes = $this->scopes; |
92 | 92 | $scope = $this->option('scope'); |
93 | - if (! empty($scope)) { |
|
93 | + if (!empty($scope)) { |
|
94 | 94 | $scopes = explode(',', $scope); |
95 | 95 | foreach ($scopes as $scope) { |
96 | - if (! in_array($scope, $this->scopes)) { |
|
96 | + if (!in_array($scope, $this->scopes)) { |
|
97 | 97 | throw new InvalidArgumentException('Scope "' . $scope . '" is not found! Available scopes is ' . implode(', ', $this->scopes)); |
98 | 98 | } |
99 | 99 | } |
@@ -101,12 +101,12 @@ discard block |
||
101 | 101 | |
102 | 102 | $path = $this->option('path', 'storage/multilang'); |
103 | 103 | $this->path = base_path($path); |
104 | - if (! is_dir($this->path)) { |
|
105 | - if (! mkdir($this->path, 0777, true)) { |
|
104 | + if (!is_dir($this->path)) { |
|
105 | + if (!mkdir($this->path, 0777, true)) { |
|
106 | 106 | throw new InvalidArgumentException('unable to create the folder "' . $this->path . '"!'); |
107 | 107 | } |
108 | 108 | } |
109 | - if (! is_writable($this->path)) { |
|
109 | + if (!is_writable($this->path)) { |
|
110 | 110 | throw new InvalidArgumentException('Folder "' . $this->path . '" is not writable!'); |
111 | 111 | } |
112 | 112 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | { |
150 | 150 | $dbTexts = $this->getTextsFromDb($scope); |
151 | 151 | |
152 | - $fileTexts = ! $clear ? $this->getTextsFromFile($scope) : []; |
|
152 | + $fileTexts = !$clear ? $this->getTextsFromFile($scope) : []; |
|
153 | 153 | |
154 | 154 | $textsToWrite = $force ? array_replace_recursive($fileTexts, $dbTexts) : array_replace_recursive($dbTexts, $fileTexts); |
155 | 155 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | |
161 | 161 | $path = $this->path . '/' . $scope . '.yml'; |
162 | 162 | $written = file_put_contents($path, $yaml); |
163 | - if (! $written) { |
|
163 | + if (!$written) { |
|
164 | 164 | $this->error('Export texts of "' . $scope . '" is failed!'); |
165 | 165 | } |
166 | 166 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | foreach ($dbTexts as $text) { |
205 | 205 | $key = $text->key; |
206 | 206 | $lang = $text->lang; |
207 | - if (! isset($formattedDbTexts[$key])) { |
|
207 | + if (!isset($formattedDbTexts[$key])) { |
|
208 | 208 | $formattedDbTexts[$key] = ['key' => $key]; |
209 | 209 | } |
210 | 210 | $formattedDbTexts[$key]['texts'][$lang] = $text->value; |
@@ -91,7 +91,7 @@ |
||
91 | 91 | |
92 | 92 | $data = str_replace('{{TEXTS_TABLE}}', $table, $content); |
93 | 93 | |
94 | - if (! file_put_contents($migrationFile, $data)) { |
|
94 | + if (!file_put_contents($migrationFile, $data)) { |
|
95 | 95 | return false; |
96 | 96 | } |
97 | 97 |
@@ -83,16 +83,16 @@ discard block |
||
83 | 83 | $this->db = $this->getDatabase(); |
84 | 84 | |
85 | 85 | $lang = $this->option('lang'); |
86 | - if (! empty($lang)) { |
|
86 | + if (!empty($lang)) { |
|
87 | 87 | $this->langs = explode(',', $lang); |
88 | 88 | } |
89 | 89 | |
90 | 90 | $scopes = $this->scopes; |
91 | 91 | $scope = $this->option('scope'); |
92 | - if (! empty($scope)) { |
|
92 | + if (!empty($scope)) { |
|
93 | 93 | $scopes = explode(',', $scope); |
94 | 94 | foreach ($scopes as $scope) { |
95 | - if (! in_array($scope, $this->scopes)) { |
|
95 | + if (!in_array($scope, $this->scopes)) { |
|
96 | 96 | throw new InvalidArgumentException('Scope "' . $scope . '" is not found! Available scopes is ' . implode(', ', $this->scopes)); |
97 | 97 | } |
98 | 98 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | |
101 | 101 | $path = $this->option('path', 'storage/multilang'); |
102 | 102 | $this->path = base_path($path); |
103 | - if (! is_dir($this->path)) { |
|
103 | + if (!is_dir($this->path)) { |
|
104 | 104 | throw new InvalidArgumentException('Folder "' . $this->path . '" is not accessible!'); |
105 | 105 | } |
106 | 106 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | protected function import($scope = 'global', $force = false) |
114 | 114 | { |
115 | 115 | $path = $this->path . '/' . $scope . '.yml'; |
116 | - if (! is_readable($path)) { |
|
116 | + if (!is_readable($path)) { |
|
117 | 117 | $this->warn('File "' . $path . '" is not readable!'); |
118 | 118 | |
119 | 119 | return false; |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $key = $text['key']; |
134 | 134 | |
135 | 135 | foreach ($text['texts'] as $lang => $value) { |
136 | - if (! empty($this->langs) && ! in_array($lang, $this->langs)) { |
|
136 | + if (!empty($this->langs) && !in_array($lang, $this->langs)) { |
|
137 | 137 | continue; |
138 | 138 | } |
139 | 139 |
@@ -50,18 +50,18 @@ discard block |
||
50 | 50 | ); |
51 | 51 | |
52 | 52 | // Register blade directives |
53 | - Blade::directive('t', function ($expression) { |
|
53 | + Blade::directive('t', function($expression) { |
|
54 | 54 | return "<?php echo e(t({$expression})); ?>"; |
55 | 55 | }); |
56 | 56 | |
57 | - $this->app['events']->listen(RouteMatched::class, function () { |
|
57 | + $this->app['events']->listen(RouteMatched::class, function() { |
|
58 | 58 | $scope = $this->app['config']->get('app.scope'); |
59 | 59 | if ($scope && $scope != 'global') { |
60 | 60 | $this->app['multilang']->setScope($scope); |
61 | 61 | } |
62 | 62 | }); |
63 | 63 | |
64 | - $this->app['events']->listen(LocaleUpdated::class, function ($event) { |
|
64 | + $this->app['events']->listen(LocaleUpdated::class, function($event) { |
|
65 | 65 | $this->app['multilang']->setLocale($event->locale); |
66 | 66 | }); |
67 | 67 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | $configPath = __DIR__ . '/../config/config.php'; |
79 | 79 | $this->mergeConfigFrom($configPath, 'debugbar'); |
80 | 80 | |
81 | - $this->app->singleton('multilang', function ($app) { |
|
81 | + $this->app->singleton('multilang', function($app) { |
|
82 | 82 | $environment = $app->environment(); |
83 | 83 | $config = $app['config']->get('multilang'); |
84 | 84 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | ); |
91 | 91 | |
92 | 92 | if ($multilang->autoSaveIsAllowed()) { |
93 | - $app->terminating(function () use ($multilang) { |
|
93 | + $app->terminating(function() use ($multilang) { |
|
94 | 94 | $scope = $this->app['config']->get('app.scope'); |
95 | 95 | if ($scope && $scope != 'global') { |
96 | 96 | $multilang->setScope($scope); |
@@ -107,28 +107,28 @@ discard block |
||
107 | 107 | |
108 | 108 | $this->app->singleton( |
109 | 109 | 'command.multilang.migration', |
110 | - function () { |
|
110 | + function() { |
|
111 | 111 | return new MigrationCommand(); |
112 | 112 | } |
113 | 113 | ); |
114 | 114 | |
115 | 115 | $this->app->singleton( |
116 | 116 | 'command.multilang.texts', |
117 | - function () { |
|
117 | + function() { |
|
118 | 118 | return new TextsCommand(); |
119 | 119 | } |
120 | 120 | ); |
121 | 121 | |
122 | 122 | $this->app->singleton( |
123 | 123 | 'command.multilang.import', |
124 | - function () { |
|
124 | + function() { |
|
125 | 125 | return new ImportCommand(); |
126 | 126 | } |
127 | 127 | ); |
128 | 128 | |
129 | 129 | $this->app->singleton( |
130 | 130 | 'command.multilang.export', |
131 | - function () { |
|
131 | + function() { |
|
132 | 132 | return new ExportCommand(); |
133 | 133 | } |
134 | 134 | ); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | public function apply(Builder $builder, Model $model) |
27 | 27 | { |
28 | 28 | |
29 | - if (! $this->queryHasLocalizableColumn($builder)) { |
|
29 | + if (!$this->queryHasLocalizableColumn($builder)) { |
|
30 | 30 | $builder->where($model->getQualifiedLocalizableColumn(), '=', app()->getLocale()); |
31 | 31 | } |
32 | 32 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | { |
42 | 42 | $wheres = $builder->getQuery()->wheres; |
43 | 43 | $column = $this->getLocalizableColumn($builder); |
44 | - if (! empty($wheres)) { |
|
44 | + if (!empty($wheres)) { |
|
45 | 45 | foreach ($wheres as $where) { |
46 | 46 | if (isset($where['column']) && $where['column'] == $column) { |
47 | 47 | return true; |