@@ -24,10 +24,10 @@  | 
                                                    ||
| 24 | 24 | $options['scope'] = $request->scope;  | 
                                                        
| 25 | 25 | }  | 
                                                        
| 26 | 26 | |
| 27 | -        $texts = Text::where(function ($q) use ($options) { | 
                                                        |
| 27 | +        $texts = Text::where(function($q) use ($options) { | 
                                                        |
| 28 | 28 |              foreach ($options as $k => $v) { | 
                                                        
| 29 | 29 |                  if ($k == 'keyword') { | 
                                                        
| 30 | -                    $q->where(function ($query) use ($v) { | 
                                                        |
| 30 | +                    $q->where(function($query) use ($v) { | 
                                                        |
| 31 | 31 |                          $query->where('key', 'LIKE', '%' . $v . '%')->orWhere('value', 'LIKE', '%' . $v . '%'); | 
                                                        
| 32 | 32 | });  | 
                                                        
| 33 | 33 |                  } else { | 
                                                        
@@ -288,9 +288,9 @@  | 
                                                    ||
| 288 | 288 | |
| 289 | 289 |          foreach ($locales as $locale => $val) { | 
                                                        
| 290 | 290 | $router->group([  | 
                                                        
| 291 | - 'prefix' => $locale,  | 
                                                        |
| 292 | - 'as' => $locale . '.',  | 
                                                        |
| 293 | - ], $callback);  | 
                                                        |
| 291 | + 'prefix' => $locale,  | 
                                                        |
| 292 | + 'as' => $locale . '.',  | 
                                                        |
| 293 | + ], $callback);  | 
                                                        |
| 294 | 294 | }  | 
                                                        
| 295 | 295 | |
| 296 | 296 | }  | 
                                                        
@@ -263,7 +263,7 @@  | 
                                                    ||
| 263 | 263 | */  | 
                                                        
| 264 | 264 | protected function sortReplacements(array $replace)  | 
                                                        
| 265 | 265 |      { | 
                                                        
| 266 | -        return (new Collection($replace))->sortBy(function ($value, $key) { | 
                                                        |
| 266 | +        return (new Collection($replace))->sortBy(function($value, $key) { | 
                                                        |
| 267 | 267 | return mb_strlen($key) * -1;  | 
                                                        
| 268 | 268 | });  | 
                                                        
| 269 | 269 | }  | 
                                                        
@@ -203,11 +203,11 @@  | 
                                                    ||
| 203 | 203 | $this->getDb()  | 
                                                        
| 204 | 204 | ->table($table)  | 
                                                        
| 205 | 205 | ->insert([  | 
                                                        
| 206 | - 'key' => $k,  | 
                                                        |
| 207 | - 'lang' => $lang,  | 
                                                        |
| 208 | - 'scope' => $scope,  | 
                                                        |
| 209 | - 'value' => $v,  | 
                                                        |
| 210 | - ]);  | 
                                                        |
| 206 | + 'key' => $k,  | 
                                                        |
| 207 | + 'lang' => $lang,  | 
                                                        |
| 208 | + 'scope' => $scope,  | 
                                                        |
| 209 | + 'value' => $v,  | 
                                                        |
| 210 | + ]);  | 
                                                        |
| 211 | 211 | }  | 
                                                        
| 212 | 212 | }  | 
                                                        
| 213 | 213 | return true;  | 
                                                        
@@ -80,7 +80,7 @@ discard block  | 
                                                    ||
| 80 | 80 |              ->where('lang', $lang); | 
                                                        
| 81 | 81 | |
| 82 | 82 |          if (!is_null($scope)) { | 
                                                        
| 83 | -            $query = $query->whereNested(function ($query) use ($scope) { | 
                                                        |
| 83 | +            $query = $query->whereNested(function($query) use ($scope) { | 
                                                        |
| 84 | 84 |                  $query->where('scope', 'global'); | 
                                                        
| 85 | 85 |                  $query->orWhere('scope', $scope); | 
                                                        
| 86 | 86 | });  | 
                                                        
@@ -113,7 +113,7 @@ discard block  | 
                                                    ||
| 113 | 113 | }  | 
                                                        
| 114 | 114 | |
| 115 | 115 |          if (!is_null($scope)) { | 
                                                        
| 116 | -            $query = $query->whereNested(function ($query) use ($scope) { | 
                                                        |
| 116 | +            $query = $query->whereNested(function($query) use ($scope) { | 
                                                        |
| 117 | 117 |                  $query->where('scope', 'global'); | 
                                                        
| 118 | 118 |                  $query->orWhere('scope', $scope); | 
                                                        
| 119 | 119 | });  | 
                                                        
@@ -39,7 +39,7 @@ discard block  | 
                                                    ||
| 39 | 39 |          $table = Config::get('multilang.db.texts_table'); | 
                                                        
| 40 | 40 | |
| 41 | 41 |          if ('' == $table) { | 
                                                        
| 42 | -            $this->error('Couldn\'t create migration.'.PHP_EOL.'Table name can\'t be empty. Check your configuration.'); | 
                                                        |
| 42 | +            $this->error('Couldn\'t create migration.' . PHP_EOL . 'Table name can\'t be empty. Check your configuration.'); | 
                                                        |
| 43 | 43 | |
| 44 | 44 | return;  | 
                                                        
| 45 | 45 | }  | 
                                                        
@@ -60,7 +60,7 @@ discard block  | 
                                                    ||
| 60 | 60 |                  $this->info('Migration successfully created!'); | 
                                                        
| 61 | 61 |              } else { | 
                                                        
| 62 | 62 | $this->error(  | 
                                                        
| 63 | - 'Couldn\'t create migration.'.PHP_EOL.' Check the write permissions  | 
                                                        |
| 63 | + 'Couldn\'t create migration.' . PHP_EOL . ' Check the write permissions  | 
                                                        |
| 64 | 64 | within the database/migrations directory.'  | 
                                                        
| 65 | 65 | );  | 
                                                        
| 66 | 66 | }  | 
                                                        
@@ -168,6 +168,7 @@ discard block  | 
                                                    ||
| 168 | 168 | /**  | 
                                                        
| 169 | 169 | * Get a texts from file.  | 
                                                        
| 170 | 170 | *  | 
                                                        
| 171 | + * @param string $scope  | 
                                                        |
| 171 | 172 | * @return array  | 
                                                        
| 172 | 173 | */  | 
                                                        
| 173 | 174 | protected function getTextsFromFile($scope)  | 
                                                        
@@ -189,6 +190,7 @@ discard block  | 
                                                    ||
| 189 | 190 | /**  | 
                                                        
| 190 | 191 | * Get a texts from database.  | 
                                                        
| 191 | 192 | *  | 
                                                        
| 193 | + * @param string $scope  | 
                                                        |
| 192 | 194 | * @return array  | 
                                                        
| 193 | 195 | */  | 
                                                        
| 194 | 196 | protected function getTextsFromDb($scope)  | 
                                                        
@@ -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;  | 
                                                        
@@ -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 | return false;  | 
                                                        
| 119 | 119 | }  | 
                                                        
@@ -131,7 +131,7 @@ discard block  | 
                                                    ||
| 131 | 131 | $key = $text['key'];  | 
                                                        
| 132 | 132 | |
| 133 | 133 |              foreach ($text['texts'] as $lang => $value) { | 
                                                        
| 134 | -                if (! empty($this->langs) && ! in_array($lang, $this->langs)) { | 
                                                        |
| 134 | +                if (!empty($this->langs) && !in_array($lang, $this->langs)) { | 
                                                        |
| 135 | 135 | continue;  | 
                                                        
| 136 | 136 | }  | 
                                                        
| 137 | 137 | |
@@ -49,11 +49,11 @@ discard block  | 
                                                    ||
| 49 | 49 | );  | 
                                                        
| 50 | 50 | |
| 51 | 51 | // Register blade directives  | 
                                                        
| 52 | -        Blade::directive('t', function ($expression) { | 
                                                        |
| 52 | +        Blade::directive('t', function($expression) { | 
                                                        |
| 53 | 53 |              return "<?php echo e(t({$expression})); ?>"; | 
                                                        
| 54 | 54 | });  | 
                                                        
| 55 | 55 | |
| 56 | -        $this->app['events']->listen(RouteMatched::class, function () { | 
                                                        |
| 56 | +        $this->app['events']->listen(RouteMatched::class, function() { | 
                                                        |
| 57 | 57 |              $scope = $this->app['config']->get('app.scope'); | 
                                                        
| 58 | 58 |              if ($scope && $scope != 'global') { | 
                                                        
| 59 | 59 | $this->app['multilang']->setScope($scope);  | 
                                                        
@@ -74,7 +74,7 @@ discard block  | 
                                                    ||
| 74 | 74 | $configPath = __DIR__ . '/../config/config.php';  | 
                                                        
| 75 | 75 | $this->mergeConfigFrom($configPath, 'debugbar');  | 
                                                        
| 76 | 76 | |
| 77 | -        $this->app->singleton('multilang', function ($app) { | 
                                                        |
| 77 | +        $this->app->singleton('multilang', function($app) { | 
                                                        |
| 78 | 78 | $environment = $app->environment();  | 
                                                        
| 79 | 79 |              $config      = $app['config']->get('multilang'); | 
                                                        
| 80 | 80 | |
@@ -86,7 +86,7 @@ discard block  | 
                                                    ||
| 86 | 86 | );  | 
                                                        
| 87 | 87 | |
| 88 | 88 |              if ($multilang->autoSaveIsAllowed()) { | 
                                                        
| 89 | -                $app->terminating(function () use ($multilang) { | 
                                                        |
| 89 | +                $app->terminating(function() use ($multilang) { | 
                                                        |
| 90 | 90 |                      $scope = $this->app['config']->get('app.scope'); | 
                                                        
| 91 | 91 |                      if ($scope && $scope != 'global') { | 
                                                        
| 92 | 92 | $multilang->setScope($scope);  | 
                                                        
@@ -102,28 +102,28 @@ discard block  | 
                                                    ||
| 102 | 102 | |
| 103 | 103 | $this->app->singleton(  | 
                                                        
| 104 | 104 | 'command.multilang.migration',  | 
                                                        
| 105 | -            function () { | 
                                                        |
| 105 | +            function() { | 
                                                        |
| 106 | 106 | return new MigrationCommand();  | 
                                                        
| 107 | 107 | }  | 
                                                        
| 108 | 108 | );  | 
                                                        
| 109 | 109 | |
| 110 | 110 | $this->app->singleton(  | 
                                                        
| 111 | 111 | 'command.multilang.texts',  | 
                                                        
| 112 | -            function () { | 
                                                        |
| 112 | +            function() { | 
                                                        |
| 113 | 113 | return new TextsCommand();  | 
                                                        
| 114 | 114 | }  | 
                                                        
| 115 | 115 | );  | 
                                                        
| 116 | 116 | |
| 117 | 117 | $this->app->singleton(  | 
                                                        
| 118 | 118 | 'command.multilang.import',  | 
                                                        
| 119 | -            function () { | 
                                                        |
| 119 | +            function() { | 
                                                        |
| 120 | 120 | return new ImportCommand();  | 
                                                        
| 121 | 121 | }  | 
                                                        
| 122 | 122 | );  | 
                                                        
| 123 | 123 | |
| 124 | 124 | $this->app->singleton(  | 
                                                        
| 125 | 125 | 'command.multilang.export',  | 
                                                        
| 126 | -            function () { | 
                                                        |
| 126 | +            function() { | 
                                                        |
| 127 | 127 | return new ExportCommand();  | 
                                                        
| 128 | 128 | }  | 
                                                        
| 129 | 129 | );  | 
                                                        
@@ -55,7 +55,7 @@  | 
                                                    ||
| 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 | *  |