spatie / laravel-translatable

Making Eloquent models translatable

Home Page:https://spatie.be/docs/laravel-translatable

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Translatable with Livewire

gizburdt opened this issue · comments

As always, awesome package! I'm trying to use this package in combination with Livewire and its model binding.
The title of the Document Model is translatable.

Livewire Component:

class Document extends Component
{
    public DocumentModel $document;

    protected $rules = [
        'document.title' => 'required|string|min:4',
    ];

    public function mount(DocumentModel $document)
    {
        $this->document = $document;
    }
}

View:

<input type="text" wire:model="document.title">

The value of the input is [object Object], which is kind of logical, since the value of title is json/array.
Normally the package will fix this with an accessor on ->title, but I think it's different with Livewire.
Do you maybe know a solution or the place I need to look to get this to work?

Thanks :)

I'd welcome a non-breaking PR with tests that makes this work 👍

I would really like to make a PR, but like I said in my previous comment, I don't know where to begin/search. Do you have any tips?