0

I'm using Laravel Backpack within Spatie Laravel Translatable. I want to pass some translatable fields into the front but I've some issues. I have a field named "extras" which is used by the backpack to store repeatable fields (I need this field to store some sections that I'll use later on the front-end later). The problem is that all the content of these repeatable fields is not transformed into an array as excepted when I try $page->toArray(). They are still regular strings instead of arrays.

public function home() {
    $page = Page::findBySlug('accueil'); 

    if(!$page) {
        abort(404);
    }
    $locale = request()->getLocale(); 

    return Inertia::render('Home', [
        'title' => $page->getTranslation('title', $locale),
        'slug' => $page->getTranslation('slug', $locale),
        'content' => $page->getTrannslation('extras', $locale)
    ]);
}

Thanks!

apokryfos
  • 38,771
  • 9
  • 70
  • 114
Harry
  • 1
  • 2
  • Can you provide what kind of response you get and what kind of response you expect? It will help to answer this question. i guess. – Vishal Tarkar Jul 22 '21 at 05:21
  • $page->getTranslation('extras', $locale) return `array: [ "section-1-title" => "Hello world", "section-1-blocs" => "[{"title": "Valeur", "content": "Bonjour"}]" ];` – Harry Jul 22 '21 at 13:34

0 Answers0