yoeunes / toastr

:eyes: toastr.js notifications for Laravel
https://php-flasher.io
MIT License
375 stars 52 forks source link

Not popping up when used in methods #33

Closed jamesautodude closed 1 year ago

jamesautodude commented 1 year ago

When using in a method like Store or Update, the toast never pops up

When used in the index method it does pop up... So it's setup correctly, it's just not working after a redirect

yoeunes commented 1 year ago

Hello @jamesautodude, thank you for bringing this issue to my attention. To better understand the problem and find a solution, please provide the following details:

If you are unable to provide a demo, please provide the following:

Providing this information will help me investigate the issue and find a solution. Thank you for your help in making toastr even better.

jamesautodude commented 1 year ago

Sorry I was in a rush

Anyways, here's some info:

Laravel version 9 PHP version 8.1 I have a simple controller with typical resources like: index, show, edit, store, update, destroy

I tried as a test, putting the following in the index() method:

public function index()
{
  toastr()->success('testing');
  return view('users.posts.index');
}

The above pops up the notice and it disappears properly

But, when I run the store() method, as well as redirect, it doesn't show... Here's a simplified example, unfortunately not my exact code but just giving an idea of the issue:

public function store(Request $request)
{
  Post::create([
      'title' => $request->title,
      'body' => $request->body,
  ]);

  toastr()->success('Post Created');
  return redirect()->route('posts.index');
}

When doing it this way, nothing shows on the posts index() view after I create a Post

jamesautodude commented 1 year ago

Hello, I ran Laravel Shift to improve/fix my coding, and now it works - so must've been some bad practice I was doing

Thank you!