Open HazemAyyad opened 4 years ago
Having the same issue with Laravel 6.
Only way I get this to work is if I use alert()->message('Message', 'Optional Title');
and also session based swal()
in my script section, which is yielded into main layout file.
For some reason in main layout file's script section the dynamic swal()
doesn't do the job.
And Facade method triggers nothing. :/ (Plus, @include('sweet::alert')
has to be in the main layout, otherwise it won't work either.)
I posted this comment here, but it's kinda related also to #93 and #115. I installed this via composer & npm, also tried with CDN. Also noticed that it didn't create its alias Alert
by itself, so I had to use FQN.
@tkaarlas @HazemAyyad
Looks like there's some bug related to the Facade. I'm digging into the code to find out the bug. All help is appreciated!
Hi, Sharing some of my findings
SweetAlert::error('Some error');
dd(Session::get('sweet_alert')); // Displays the sweet alert config
return redirect()->route('some-route');
dd(Session::get('sweet_alert')); // Displays 'null'
The helper alert()->error()
doesn't work for me either. Im running Laravel 6.x. There might be some problems with the Session dependency or something has changed with how Laravel redirects. Will continue looking further and will update you when something comes up.
Hi, I found the problem with the facades. the __destruct
method is not triggered.
I then tried placing the $this->flashConfig()
inside message()
method and it works as intended.
THANKS "juliomotol" ! It's work for me ! -> I add "$this->flashConfig();" into the public function "message ()"
did you put "$this->flashConfig();" in the __destruct() or did you remove it?
did you put "$this->flashConfig();" in the __destruct() or did you remove it?
Neither, I was just trying to figure out what could have been the problem and tried hacking the code a bit. I'd suggest using the helper functions for now until this is fixed.
i used use UxWeb\SweetAlert\SweetAlert; SweetAlert::success('Success Message', 'Added Done '); i used in blade.php
@include('sweet::alert') i used in // config/app.php 'providers' => [ UxWeb\SweetAlert\SweetAlertServiceProvider::class, ];
'aliases' => [ 'Alert' => UxWeb\SweetAlert\SweetAlert::class, ];