Handle fields manually in order to have empty translations too

parent 77fb6169
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Modules\Page\Transformers; namespace Modules\Page\Transformers;
use Illuminate\Http\Resources\Json\Resource; use Illuminate\Http\Resources\Json\Resource;
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
class FullPageTransformer extends Resource class FullPageTransformer extends Resource
{ {
...@@ -14,9 +15,12 @@ class FullPageTransformer extends Resource ...@@ -14,9 +15,12 @@ class FullPageTransformer extends Resource
'is_home' => $this->is_home, 'is_home' => $this->is_home,
]; ];
foreach ($this->translations as $pageTranslation) { foreach (LaravelLocalization::getSupportedLocales() as $locale => $supportedLocale) {
$pageData[$pageTranslation->locale] = $pageTranslation; foreach ($this->translatedAttributes as $translatedAttribute) {
$pageData[$locale][$translatedAttribute] = $this->translateOrNew($locale)->$translatedAttribute;
}
} }
foreach ($this->tags as $tag) { foreach ($this->tags as $tag) {
$pageData['tags'][] = $tag->name; $pageData['tags'][] = $tag->name;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment