@@ -11,7 +11,7 @@ |
||
| 11 | 11 | protected $namespace = 'Modules\Translation\Http\Controllers'; |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | - * @return string |
|
| 14 | + * @return boolean |
|
| 15 | 15 | */ |
| 16 | 16 | protected function getFrontendRoute() |
| 17 | 17 | { |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | protected function getBackendRoute() |
| 25 | 25 | { |
| 26 | - return __DIR__ . '/../Http/backendRoutes.php'; |
|
| 26 | + return __DIR__.'/../Http/backendRoutes.php'; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -31,6 +31,6 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | protected function getApiRoute() |
| 33 | 33 | { |
| 34 | - return __DIR__ . '/../Http/apiRoutes.php'; |
|
| 34 | + return __DIR__.'/../Http/apiRoutes.php'; |
|
| 35 | 35 | } |
| 36 | 36 | } |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | public function up() |
| 13 | 13 | { |
| 14 | - Schema::create('translation__translations', function (Blueprint $table) { |
|
| 14 | + Schema::create('translation__translations', function(Blueprint $table) { |
|
| 15 | 15 | $table->engine = 'InnoDB'; |
| 16 | 16 | $table->increments('id'); |
| 17 | 17 | $table->string('key'); |
@@ -12,14 +12,14 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | public function up() |
| 14 | 14 | { |
| 15 | - Schema::create('translation__translation_translations', function (Blueprint $table) { |
|
| 15 | + Schema::create('translation__translation_translations', function(Blueprint $table) { |
|
| 16 | 16 | $table->engine = 'InnoDB'; |
| 17 | 17 | $table->increments('id'); |
| 18 | 18 | $table->text('value'); |
| 19 | 19 | |
| 20 | 20 | $table->integer('translation_id')->unsigned(); |
| 21 | 21 | $table->string('locale')->index(); |
| 22 | - $table->unique(['translation_id', 'locale'], 'translations_trans_id_locale_unique'); |
|
| 22 | + $table->unique([ 'translation_id', 'locale' ], 'translations_trans_id_locale_unique'); |
|
| 23 | 23 | $table->foreign('translation_id')->references('id')->on('translation__translations')->onDelete('cascade'); |
| 24 | 24 | }); |
| 25 | 25 | } |
@@ -8,6 +8,6 @@ |
||
| 8 | 8 | use Translatable; |
| 9 | 9 | |
| 10 | 10 | protected $table = 'translation__translations'; |
| 11 | - public $translatedAttributes = ['value']; |
|
| 12 | - protected $fillable = ['key', 'value']; |
|
| 11 | + public $translatedAttributes = [ 'value' ]; |
|
| 12 | + protected $fillable = [ 'key', 'value' ]; |
|
| 13 | 13 | } |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | public function rules() |
| 8 | 8 | { |
| 9 | 9 | return [ |
| 10 | - 'file' => ['required', 'extensions:csv'], |
|
| 10 | + 'file' => [ 'required', 'extensions:csv' ], |
|
| 11 | 11 | ]; |
| 12 | 12 | } |
| 13 | 13 | |
@@ -19,11 +19,11 @@ discard block |
||
| 19 | 19 | public function import(UploadedFile $file) |
| 20 | 20 | { |
| 21 | 21 | $csv = Reader::createFromPath($file->getRealPath()); |
| 22 | - $csv->detectDelimiterList(5, [',', ';']); |
|
| 22 | + $csv->detectDelimiterList(5, [ ',', ';' ]); |
|
| 23 | 23 | $headers = $csv->fetchOne(); |
| 24 | 24 | $csv->setOffset(1); |
| 25 | 25 | |
| 26 | - $csv->each(function ($row) use ($headers) { |
|
| 26 | + $csv->each(function($row) use ($headers) { |
|
| 27 | 27 | try { |
| 28 | 28 | $row = array_combine($headers, $row); |
| 29 | 29 | } catch (\Exception $e) { |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | $key = array_get($row, 'key'); |
| 34 | 34 | array_shift($row); |
| 35 | - $data = []; |
|
| 35 | + $data = [ ]; |
|
| 36 | 36 | foreach ($row as $locale => $value) { |
| 37 | - $data[$locale] = ['value' => $value]; |
|
| 37 | + $data[ $locale ] = [ 'value' => $value ]; |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | $this->translation->updateFromImport($key, $data); |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | return $this->cache |
| 23 | 23 | ->tags($this->entityName, 'global') |
| 24 | 24 | ->rememberForever("{$this->locale}.{$this->entityName}.findByKeyAndLocale.{$key}.{$locale}", |
| 25 | - function () use ($key, $locale) { |
|
| 25 | + function() use ($key, $locale) { |
|
| 26 | 26 | return $this->repository->findByKeyAndLocale($key, $locale); |
| 27 | 27 | } |
| 28 | 28 | ); |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | return $this->cache |
| 34 | 34 | ->tags($this->entityName, 'global') |
| 35 | 35 | ->rememberForever("{$this->locale}.{$this->entityName}.allFormatted", |
| 36 | - function () { |
|
| 36 | + function() { |
|
| 37 | 37 | return $this->repository->allFormatted(); |
| 38 | 38 | } |
| 39 | 39 | ); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | return $this->cache |
| 52 | 52 | ->tags($this->entityName, 'global') |
| 53 | 53 | ->rememberForever("{$this->locale}.{$this->entityName}.findTranslationByKey.{$key}", |
| 54 | - function () use ($key) { |
|
| 54 | + function() use ($key) { |
|
| 55 | 55 | return $this->repository->findTranslationByKey($key); |
| 56 | 56 | } |
| 57 | 57 | ); |
@@ -25,11 +25,11 @@ discard block |
||
| 25 | 25 | public function allFormatted() |
| 26 | 26 | { |
| 27 | 27 | $allRows = $this->all(); |
| 28 | - $allDatabaseTranslations = []; |
|
| 28 | + $allDatabaseTranslations = [ ]; |
|
| 29 | 29 | foreach ($allRows as $translation) { |
| 30 | 30 | foreach (config('laravellocalization.supportedLocales') as $locale => $language) { |
| 31 | 31 | if ($translation->hasTranslation($locale)) { |
| 32 | - $allDatabaseTranslations[$locale][$translation->key] = $translation->translate($locale)->value; |
|
| 32 | + $allDatabaseTranslations[ $locale ][ $translation->key ] = $translation->translate($locale)->value; |
|
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | public function findTranslationByKey($key) |
| 48 | 48 | { |
| 49 | - return $this->model->firstOrCreate(['key' => $key]); |
|
| 49 | + return $this->model->firstOrCreate([ 'key' => $key ]); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | foreach ($allFileTranslations as $locale => $fileTranslation) { |
| 34 | 34 | foreach ($fileTranslation as $key => $translation) { |
| 35 | - if (isset($allDatabaseTranslations[$locale][$key])) { |
|
| 36 | - $allFileTranslations[$locale][$key] = $allDatabaseTranslations[$locale][$key]; |
|
| 37 | - unset($allDatabaseTranslations[$locale][$key]); |
|
| 35 | + if (isset($allDatabaseTranslations[ $locale ][ $key ])) { |
|
| 36 | + $allFileTranslations[ $locale ][ $key ] = $allDatabaseTranslations[ $locale ][ $key ]; |
|
| 37 | + unset($allDatabaseTranslations[ $locale ][ $key ]); |
|
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | $activeLocales = $this->getActiveLocales(); |
| 55 | 55 | |
| 56 | 56 | foreach ($allFileTranslations as $locale => $value) { |
| 57 | - if (! in_array($locale, $activeLocales)) { |
|
| 58 | - unset($allFileTranslations[$locale]); |
|
| 57 | + if (!in_array($locale, $activeLocales)) { |
|
| 58 | + unset($allFileTranslations[ $locale ]); |
|
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -66,10 +66,10 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | private function getActiveLocales() |
| 68 | 68 | { |
| 69 | - $locales = []; |
|
| 69 | + $locales = [ ]; |
|
| 70 | 70 | |
| 71 | 71 | foreach (config('laravellocalization.supportedLocales') as $locale => $translation) { |
| 72 | - $locales[] = $locale; |
|
| 72 | + $locales[ ] = $locale; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | return $locales; |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | { |
| 84 | 84 | foreach ($allDatabaseTranslations as $locale => $group) { |
| 85 | 85 | foreach ($group as $key => $value) { |
| 86 | - $allFileTranslations[$locale][$key] = $value; |
|
| 86 | + $allFileTranslations[ $locale ][ $key ] = $value; |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | } |