Thanx for the package. I include it in my actual project :)
Sweet Alert Messages for You!
Hi guys!
I just released a package named uxweb/sweet-alert.
This package will let you show beautiful alert messages to your Laravel app users.
The ones that are displayed here on Laracasts when you create or update a new conversation.
If you are using the laracasts/flash, you already are in good shape to use this package.
Note: this is not a replacement for laracasts/flash and is not intended to use on every possible situation a message should be shown.
The package uses this great library:
http://t4t5.github.io/sweetalert/
Check the repo on Github at:
https://github.com/uxweb/sweet-alert
If you have any doubt please reply :)
Thanks.
Can you string them onto the redirect()?
@lolotoobo Thanks guys, i had some issues with the psr-4 autoloader in version 1.02 through 1.0.4, if you have any issue please install 1.0.5 version
@bashy I think right now it does not do it that way. Can you explain more this?.
Currently this package uses the laravel session to store the message.
Like instead of
alert()->success('You have been logged out.', 'Good bye!');
return home();
you can do
return home()->alert()->success('You have been logged out.', 'Good bye!');
Hi @uxweb,
Just trying this out. I did the composer dance. I added the service provider and the facade. In PHPStorm it does not like this.
\Route::get('menu', function()
{
Alert::message('Welcome back!');
return view('coverage');
});
It cannot resolve the Alert facade. However it does like:
\Route::get('menu', function()
{
SweetAlert::message('Welcome back!');
return view('coverage');
});
I took Alert:: ... straight from your Git Readme section.
But I get no alert box? i am confused by what is expected to happen? I expect an alert message and then my normal view.
Just trying this out. Normally I don't launch alert boxes from the server side code.
Note I published the view to resources/vendor
I am basing my code off your example:
public function store()
{
Alert::message('Welcome Back!');
return Redirect::home();
}
Jim
Thanks for the feedback @jimmck, did you linked the JS and CSS files from Sweet Alert?
@bashy I think i'm not sure how to do that. This is my first package, i'm still a noob, but let me check if it is possible to extend the Redirector with the SweetAlert functionality.
If you have more ideas on how to implement this i'll appreciate your help!
Thank you :)
Hi,
Yes. I think it's inn how I am trying to use your stuff. Here is the view:
<!doctype html>
<html>
<title>Coverage</title>
<link rel="stylesheet" href="/assets/css/coverage.css">
<link rel="stylesheet" href="/assets/css/sweetalert.css">
<body>
<script src="/assets/js/jquery-1.10.2.js"></script>
<script src="/assets/js/sweetalert.min.js"></script>
<!-- Include this after you include the sweet alert js file -->
@include('sweet::alert')
@yield('content')
<script>
(function() {
var wrap = $('div#app');
var melissa;
//alert("Started...");
$('a').on('click', function( e ) {
var href = $(this).attr('href');
wrap.load( href );
e.preventDefault();
});
})();
</script>
</body>
</html>
And then then the Route. I am using the Message construct (I guess??) from your store example. I don't see how you are setting up the alert dialog in JS? I am used to doing this on the client side. In my alerts the server sends data and the alert displays it.
The route:
\Route::get('menu', function()
{
SweetAlert::message('Welcome back!');
return view('coverage');
});
The coverage view is the blade layout you see.
Jim
@uxweb I am assuming I can do this right in the route for testing and skip the controller? Whats up with the SweetAlert? The facade I registered is Alert? Sorry did not read your code all the way through. Laravel cannot load your service via Alert facade, the lookup fails.
@jimmck Just fixed a bug within the view template included. Please do a composer update to get the 1.0.6 version and delete the directory published in resources/views/vendor/sweet-alert.
Just created a new Laravel project to test what you are trying to do, it works fine using the Alert facade in a route closure like this:
Route::get('/alert', function() {
Alert::message('Hey!');
return view('app');
});
It works good. When using the Alert facade, do you get any errors? maybe prefixing it with a "" like this:
\Alert::message('Hey!');
Thanks again for your feedback!
@uxweb Cool I will update and let you know! Excellent Customer Service :)
@uxweb Hey it works!!!!! But alas, PHPStorm insists on SweetAlert::message('Your Message Goes Here");
Alert::message gives this Stacktrace:
Great work!!!
How does this work? It has great applications!!!
Jim
\Route::get('menu', function()
{
Alert::message('Welcome back!');
return view('coverage');
});
Works
I just get a flash message and my menu view together. There is no button to press for SweetAlert message. Is that the expectation?
Lemme know if you want me to try anything.
Jim
@jimmck Yep, dismissing the alert after some seconds is the default behavior, but it can be changed.
If you want the alert has a confirm button to close do it like:
Alert::message('Thanks for your help!')->persistent('Close Me!');
This will override the default dismissible alert and will only close if you press the alert button.
What did you do to fix the Alert facade?
Thank you!
I did not do anything. Alert::message does not work. See prev message with stacktrace.
Sorry did not switch back, this works...
\Route::get('menu', function()
{
SweetAlert::message('Welcome back!');
return view('coverage');
});
It kinda looks like I could do some weird css/div magic to blend these two views????
@jimmck, mmm, it looks pretty strange that the Alert facade is not working.
Did you added it to your aliases section in config/app.php?, like this:
'aliases' => [
// more default laravel aliases
'Alert' => 'UxWeb\SweetAlert\SweetAlert',
],
Thank you!
@uxweb Hey I was looking at the error. FYI I have the HTML stuff loaded as well. From Laravel 4... If that helps.
@jimmck Ohh i see, are you using Laravel 4?, if so, that explains why it may be failing.
I did this for Laravel 5, but let me test it in L4, i think i will need to make a new branch to support to L4.
Thank you!
Yes I did...
'Spatie\Backup\BackupServiceProvider',
'Spatie\Tail\TailServiceProvider',
'Kris\LaravelFormBuilder\FormBuilderServiceProvider',
FintechFab\LaravelQueueRabbitMQ\LaravelQueueRabbitMQServiceProvider::class,
'Barryvdh\Debugbar\ServiceProvider',
'Illuminate\Html\HtmlServiceProvider',
'UxWeb\SweetAlert\SweetAlertServiceProvider',
'FormBuilder' => 'Kris\LaravelFormBuilder\Facades\FormBuilder',
'Form' => 'Illuminate\Html\FormFacade',
'Debugbar' => 'Barryvdh\Debugbar\Facade',
'HTML' => 'Illuminate\Html\HtmlFacade',
'Alert' => 'Uxweb\SweetAlert\SweetAlert',
No I am Laravel 5.1.7. I load the HTML stuff separate.
@jimmck I think there is a typo in the Facade namespace in your app config file, change Uxweb for UxWeb and give it a try.
Thank you!
Jamess-MacBook-Pro:laravel5 jimm$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Removing psy/psysh (v0.4.4)
- Installing psy/psysh (v0.5.1)
Downloading: 100%
- Removing laravel/framework (v5.1.6)
- Installing laravel/framework (v5.1.7)
Downloading: 100%
- Removing uxweb/sweet-alert (1.0.5)
- Installing uxweb/sweet-alert (1.0.6)
Downloading: 100%
Writing lock file
Generating autoload files
Generating optimized class loader
Jamess-MacBook-Pro:laravel5 jimm$ php artisan vendor:publish
Copied Directory [/vendor/kris/laravel-form-builder/src/views] To [/resources/views/vendor/laravel-form-builder]
Copied Directory [/vendor/uxweb/sweet-alert/src/views] To [/resources/views/vendor/sweet]
Publishing complete for tag []!
Jamess-MacBook-Pro:laravel5 jimm$
@jimmck Thanks for share that composer output.
Then if you are using L5 i think the only thing that makes the facade fails is that namespace typo in the aliases list.
@jimmck My bad, i have that typo in documentation, i'm improving it and fixing some other typos.
I appreciate your help A LOT!.
No I made the change, does not work. I cut/pasted Facade entry from your GIT Readme you will need to update.
@uxweb Hi, I never wrote a Facade class but compare yours to the HTML Facade class
<?php
namespace UxWeb\SweetAlert;
use Illuminate\Support\Facades\Facade;
class SweetAlert extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'uxweb.sweet-alert';
}
}
and HTML's
<?php namespace Illuminate\Html;
use Illuminate\Support\Facades\Facade;
/**
* @see \Illuminate\Html\HtmlBuilder
*/
class HtmlFacade extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor() { return 'html'; }
}
Please or to participate in this conversation.

