@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | function getLocales() |
| 18 | 18 | { |
| 19 | - $locales = collect(config('translatable.locales'))->map(function ($locale, $index) { |
|
| 20 | - return collect($locale)->map(function ($country) use ($locale, $index) { |
|
| 19 | + $locales = collect(config('translatable.locales'))->map(function($locale, $index) { |
|
| 20 | + return collect($locale)->map(function($country) use ($locale, $index) { |
|
| 21 | 21 | return is_numeric($index) |
| 22 | 22 | ? $locale |
| 23 | 23 | : "$index-$country"; |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | { |
| 43 | 43 | $manageMultipleLanguages = count(getLocales()) > 1; |
| 44 | 44 | if ($manageMultipleLanguages && $translate) { |
| 45 | - $allLanguages = Collection::make(getLocales())->map(function ($locale, $index) use ($form_fields) { |
|
| 45 | + $allLanguages = Collection::make(getLocales())->map(function($locale, $index) use ($form_fields) { |
|
| 46 | 46 | return [ |
| 47 | 47 | 'shortlabel' => strtoupper($locale), |
| 48 | 48 | 'label' => getLanguageLabelFromLocaleCode($locale), |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | if (method_exists($query->getModel(), 'translations')) { |
| 26 | 26 | $locale = $locale == null ? app()->getLocale() : $locale; |
| 27 | 27 | |
| 28 | - $query->whereHas('translations', function ($query) use ($locale) { |
|
| 28 | + $query->whereHas('translations', function($query) use ($locale) { |
|
| 29 | 29 | $query->whereActive(true); |
| 30 | 30 | $query->whereLocale($locale); |
| 31 | 31 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | } |
| 35 | 35 | }); |
| 36 | 36 | |
| 37 | - return $query->with(['translations' => function ($query) use ($locale) { |
|
| 37 | + return $query->with(['translations' => function($query) use ($locale) { |
|
| 38 | 38 | $query->whereActive(true); |
| 39 | 39 | $query->whereLocale($locale); |
| 40 | 40 | |
@@ -54,14 +54,14 @@ discard block |
||
| 54 | 54 | $locale = $locale == null ? app()->getLocale() : $locale; |
| 55 | 55 | |
| 56 | 56 | return $query |
| 57 | - ->join($translationTable, function (JoinClause $join) use ($translationTable, $localeKey, $table, $keyName) { |
|
| 57 | + ->join($translationTable, function(JoinClause $join) use ($translationTable, $localeKey, $table, $keyName) { |
|
| 58 | 58 | $join |
| 59 | - ->on($translationTable.'.'.$this->getRelationKey(), '=', $table.'.'.$keyName) |
|
| 60 | - ->where($translationTable.'.'.$localeKey, $this->locale()); |
|
| 59 | + ->on($translationTable . '.' . $this->getRelationKey(), '=', $table . '.' . $keyName) |
|
| 60 | + ->where($translationTable . '.' . $localeKey, $this->locale()); |
|
| 61 | 61 | }) |
| 62 | - ->where($translationTable.'.'.$this->getLocaleKey(), $locale) |
|
| 63 | - ->orderBy($translationTable.'.'.$orderField, $orderType) |
|
| 64 | - ->select($table.'.*') |
|
| 62 | + ->where($translationTable . '.' . $this->getLocaleKey(), $locale) |
|
| 63 | + ->orderBy($translationTable . '.' . $orderField, $orderType) |
|
| 64 | + ->select($table . '.*') |
|
| 65 | 65 | ->with('translations'); |
| 66 | 66 | } |
| 67 | 67 | |
@@ -97,14 +97,14 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | public function getActiveLanguages() |
| 99 | 99 | { |
| 100 | - return $this->translations->map(function ($translation) { |
|
| 100 | + return $this->translations->map(function($translation) { |
|
| 101 | 101 | return [ |
| 102 | 102 | 'shortlabel' => strtoupper($translation->locale), |
| 103 | 103 | 'label' => getLanguageLabelFromLocaleCode($translation->locale), |
| 104 | 104 | 'value' => $translation->locale, |
| 105 | 105 | 'published' => $translation->active ?? false, |
| 106 | 106 | ]; |
| 107 | - })->sortBy(function ($translation) { |
|
| 107 | + })->sortBy(function($translation) { |
|
| 108 | 108 | $localesOrdered = getLocales(); |
| 109 | 109 | return array_search($translation['value'], $localesOrdered); |
| 110 | 110 | })->values(); |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | public function translatedAttribute($key) |
| 114 | 114 | { |
| 115 | - return $this->translations->mapWithKeys(function ($translation) use ($key) { |
|
| 115 | + return $this->translations->mapWithKeys(function($translation) use ($key) { |
|
| 116 | 116 | return [$translation->locale => $this->translate($translation->locale)->$key]; |
| 117 | 117 | }); |
| 118 | 118 | } |