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

toastr shows up again when trying to go back #36

Open
2jiwon opened this issue Mar 27, 2023 · 5 comments
Open

toastr shows up again when trying to go back #36

2jiwon opened this issue Mar 27, 2023 · 5 comments

Comments

@2jiwon
Copy link

2jiwon commented Mar 27, 2023

Hello,
I am using toastr and it's a great package.

Actually, I have a question.
toastr message shows up again when I try to go back on view page.

Here's some part of my code.
// controller

toastr()->success('complete. \\n'.$return, '', ['timeOut' => 5000, 'positionClass' => 'toast-center-center']);
return redirect()->back();

// blade

@if (Session::has('success'))
         <div class="row justify-content-end">
               <div class="col-3 col-align-self-end alert alert-success alert-block">
                   <button type="button" class="close" data-dismiss="alert">×</button>
                       <strong>
                          toastr.success("{{ $message }}");
                        </strong>
                 </div>
          </div>
@endif

....

<!-- container-fluid end -->

@toastr_css
@toastr_js
@toastr_render

Did I do something wrong here? Or could you tell me where should I check for?

@yoeunes
Copy link
Owner

yoeunes commented Mar 27, 2023

Hello @2jiwon, thank you for using the yoeunes/toastr package. I noticed that you are currently using an outdated version of the package. To resolve any potential issues, I would recommend upgrading to the latest version by running the following command: composer require yoeunes/toastr::^2.3.

Additionally, I suggest removing all the code related to the outdated version from your blade template. This should help ensure that the latest version works seamlessly with your project. Thank you again for using this package, and please let me know if you have any questions or concerns.

@2jiwon
Copy link
Author

2jiwon commented Apr 5, 2023

@yoeunes Thank you for your reply. I tried what you suggested composer require yoeunes/toastr::^2.3 then it says

 [UnexpectedValueException]                                                
  Could not parse version constraint :^2.3: Invalid version string ":^2.3"

so I also tried composer require yoeunes/toastr^2.3 just in case, but it didn't work either.

@2jiwon
Copy link
Author

2jiwon commented Apr 5, 2023

@yoeunes oops, nevermind. it was because my composer version. I was able to update to 2.3.
However, the situation that showing up twice is still exists.

@yoeunes
Copy link
Owner

yoeunes commented Apr 5, 2023

please remove all this code from your blade template:

@if (Session::has('success'))
         <div class="row justify-content-end">
               <div class="col-3 col-align-self-end alert alert-success alert-block">
                   <button type="button" class="close" data-dismiss="alert">×</button>
                       <strong>
                          toastr.success("{{ $message }}");
                        </strong>
                 </div>
          </div>
@endif

....

<!-- container-fluid end -->

@toastr_css
@toastr_js
@toastr_render

@madfortech
Copy link

madfortech commented Aug 11, 2023

when i add this
layout app.blade.php
@toastr_css
@toastr_js
@toastr_render
Capture1

PHP 8.1.17 (cli) (built: Mar 14 2023 23:07:43) (ZTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.1.17, Copyright (c) Zend Technologies

laravel . 10.18.0 version

Here my PostController Code
$post = Post::create([
'title' => $request->input('title'),
'description' => $request->input('description'),
'slug' => Str::slug($request->input('title')), // Generate slug
]);

    if ($request->hasFile('avatar')) {
        $post->addMedia($request->file('avatar'))
            ->toMediaCollection('avatars'); // You can customize the collection name as needed
    }

    
    toastr()::success('Post created successfully!', 'Success'); // Display a success toast message
    //
          Undefined function 'App\Http\Controllers\toastr'
    //
    any one help me fix htis 

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

No branches or pull requests

3 participants