Transform all repeatable fileds into array - laravel backpack (fake fields)

501 Views Asked by At

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!

0

There are 0 best solutions below