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

not show sweetalert laravel5.8 #118

Open
HazemAyyad opened this issue Jan 15, 2020 · 6 comments
Open

not show sweetalert laravel5.8 #118

HazemAyyad opened this issue Jan 15, 2020 · 6 comments

Comments

@HazemAyyad
Copy link

i used use UxWeb\SweetAlert\SweetAlert;
SweetAlert::success('Success Message', 'Added Done ');
i used in blade.php

<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>

@include('sweet::alert')
i used in // config/app.php
'providers' => [
UxWeb\SweetAlert\SweetAlertServiceProvider::class,
];

'aliases' => [
'Alert' => UxWeb\SweetAlert\SweetAlert::class,
];

@HazemAyyad HazemAyyad changed the title not show sweetalert not show sweetalert laravel5.8 Jan 15, 2020
@tkaarlas
Copy link

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.

@uxweb
Copy link
Owner

uxweb commented Jan 30, 2020

@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!

@juliomotol
Copy link

juliomotol commented Mar 5, 2020

Hi, Sharing some of my findings

First Controller Action

SweetAlert::error('Some error');

dd(Session::get('sweet_alert')); // Displays the sweet alert config

return redirect()->route('some-route');

'some-route' Controller action

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.

@juliomotol
Copy link

Hi, I found the problem with the facades. the __destruct method is not triggered.

public function __destruct()
{
$this->flashConfig();
}

I then tried placing the $this->flashConfig() inside message() method and it works as intended.

@rabishmuel
Copy link

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?

@juliomotol
Copy link

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.

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

No branches or pull requests

5 participants