livewire-flash icon indicating copy to clipboard operation
livewire-flash copied to clipboard

Dependancy errors using for first time

Open longestdrive opened this issue 1 month ago • 1 comments

Hi

Just installed your package as having issues trying to get flash messages to work on livewire pages without needing a redirect.

I have previously used Laracasts/Flash and wondering if this is creating a conflict - I have subsequently removed that package but problems persist:

I have this route for testing:

Route::get('flash', function () {
        flash('Success!!!!!')->success();
        return view('sandpit.flash');
    });

I have this view:

<p>Flash 2</p>
@ray(session()->all())
<livewire:flash-message />

I get this error when trying to view that page:

Unable to resolve dependency [Parameter #0 [ <required> $message ]] in class MattLibera\LivewireFlash\Livewire\FlashMessage

Inspecting the session data I have:

array:6 [▼
  "_token" => "XJiChWm9XSa1Fw94sYwkRPqZcGY5ScPmK6XMBLWE"
  "url" => array:1 [▶]
  "_previous" => array:1 [▶]
  "_flash" => array:2 [▼
    "old" => []
    "new" => array:1 [▼
      0 => "flash_notification"
    ]
  ]
  "login_web_59ba36addc2b2f9401580f014c7f58ea4e30989d" => 1
  "flash_notification" => 
Illuminate\Support
\
Collection {#2149 ▼
    #items: array:1 [▼
      0 => 
Laracasts\Flash
\
Message {#2147 ▼
        +title: null
        +message: "Success!!!!!"
        +level: "success"
        +important: false
        +overlay: false
      }
    ]
    #escapeWhenCastingToString: false
  }
]

I can see from that the collection relates to Laracasts\Flash - I couldn’t see that as a dependency in your package and wonder if it's a hangover from previously using Flash? I've cleared the view, config and cache and composer update and dump-autoload.

What am I missing to get this package to work?, which I'm hoping to be a life saver!!

longestdrive avatar Jan 22 '25 17:01 longestdrive