mattlibera / livewire-flash

A Laravel Livewire-based Flash message component
MIT License
118 stars 17 forks source link

Method success() not found #4

Closed elfeffe closed 4 years ago

elfeffe commented 4 years ago

I'm using this: flash('Your request was successful!')->success()->livewire($this);

And in fact, I don't see success function

mattlibera commented 4 years ago

You're definitely using <livewire:flash-container /> somewhere in your template, right?

Have you published the config? If so, is there an entry for success in your styles array? Like:

'styles' => [
        'success' => [
            'bg-color'     => 'bg-green-100',
            'border-color' => 'border-green-400',
            'icon-color'   => 'text-green-400',
            'text-color'   => 'text-green-800',
            'icon'         => 'fas fa-check',
        ],

The flash notifier uses the magic __call() method and keys off of the entries in that array, so if you don't have a success entry, then ->success() won't be found. That's the first thing that comes to mind if you're seeing a "method not found" error.

Let's start there.

elfeffe commented 4 years ago

Yes I have it working, and it's working great, thank you.

About success, yes, I have published it, I will check what is happening. For now I just use it like ($message, $level)

elfeffe commented 4 years ago

The error is

Call to a member function livewire() on null

And this is my code: flash('Your account was created.')->success()->livewire($this);

mattlibera commented 4 years ago

Ahh ok. I think I have figured out where the problem is - I believe the __call() method should be returning the class and is not.

I will test a fix and keep you posted.

mattlibera commented 4 years ago

@elfeffe Yep, that did it. Turns out I broke this in the last update and didn't catch it. Just tagged 0.3.1 - go ahead and update and see if that fixes the issue.