Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package not working correctly with livewire #236

Open
RolandVerner opened this issue Jul 28, 2021 · 3 comments
Open

Package not working correctly with livewire #236

RolandVerner opened this issue Jul 28, 2021 · 3 comments

Comments

@RolandVerner
Copy link

RolandVerner commented Jul 28, 2021

It's not possible to use wire.model.defer with this package in livewire

@CrazyBoy49z
Copy link

+1

1 similar comment
@MohmmedAshraf
Copy link

+1

@CrazyBoy49z
Copy link

Syntax PHP 8+

public function mount(Blog $blog): void
    {
        $this->blog = $blog->loadMissing(['seo', 'translations']);

...
        if ($this->blog->exists) {
            $this->translations = $this->blog?->getTranslationsArray();
        }
....
        collect(array_keys($this->locales))->each(function ($key) {
            if (empty($this->translations[$key])) {
                $this->translations[$key]['title'] ??= '';
                $this->translations[$key]['longtitle'] ??= '';
                $this->translations[$key]['description'] ??= '';
                $this->translations[$key]['content'] ??= '';
            }
        });
    }

public function save(): void
    {
        $this->blog->fill($this->translations);
        $this->blog->slug ??= str($this->blog->translateOrDefault('en')?->title)->slug();
        $this->validated();
        ....
        $this->blog->save();
        ....
    }


Or use DTO https://laravel-livewire.com/docs/2.x/properties#wireable-properties

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants