Download the PHP package hadefication/siren without Composer
On this page you can find all versions of the php package hadefication/siren. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package siren
Siren
Toast style application messages for [Laravel]() using [toastr]().
Installation
- Install by running
composer require hadefication/siren
. - Add the service provider and facade to your
config/app.php
.
Usage
-
To collect messages, you can either use the facade
Siren
or the nifty little helper function calledsiren()
. This then will give you access to all of the methods that siren can offer. To collect an error message, usesiren()->error($message, $title, $important)
where$message
will obviously the message you want to convey and same goes to$title
then$important
will determine if your message will stay until it's closed (set totrue
) or will auto-close after a number of seconds. See example below for the type of message that can be collected using siren. -
Next is you need to include the companion javascript library by either requiring it to your
app.js
or adding it directly to your view. You may need to copyvendor/src/resources/assets/dist/siren.js
to your public path if your going for the later option. Luckily, [Laravel Elixir]() or [Laravel Mix]() can do that for you! Once the javascript library is added, you will then havesiren
global variable at your disposal, see Javascript section for more details. - To show the toast messages, you need to add
siren()->render()
or\Siren::render()
at the tail of your layout's view. It's important that this method will be the last one to be called.
Javascript
The companion javascript library uses this cool plugin called [toastr]() to render the toast style message. Once the javascript library is referenced, then you will be able to access siren
variable, this variable will then give you access to all methods that this library has to offer.
-
siren.setDefaults(options)
- will let you override the default settings of toastr.options
param will be the overrides that you want. siren.error(message, title, important, options)
- will show an error toast message.message
will obviously the message to show and same goes totitle
thenimportant
will be the flag if you want the message to stay until closed or auto-closed after a period of time and finally theoptions
param will give you the "option" to override the defaults of toastr. These will also be the same for other message types. See example below for more details.