Skip to content
Notifying your users doesn't have to be a lot of work.
PHP HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Create FUNDING.yml Oct 18, 2019
config WIP - rewritting from scratch for Laravel 5.5 Sep 10, 2017
resources/views WIP Sep 15, 2017
routes Add unit tests Sep 14, 2017
src WIP - refactor to message model Sep 15, 2017
tests Update dependencies. Aug 29, 2019
.gitignore Update dependencies. Aug 29, 2019
.travis.yml Update dependencies. Aug 29, 2019
CODE_OF_CONDUCT.md Add code of conduct Sep 15, 2017
CONTRIBUTING.md Create CONTRIBUTING.md Sep 15, 2017
ISSUE_TEMPLATE.md Add issue template Sep 10, 2017
LICENSE Update license Sep 10, 2017
README.md Update README.md Oct 18, 2019
composer.json Update to Laravel 6.0 Sep 5, 2019
phpunit.xml WIP Sep 11, 2017

README.md

Messenger for Laravel

Join the chat at https://gitter.im/GeneaLabs/laravel-messenger Travis SensioLabs Insight Scrutinizer Coveralls GitHub (pre-)release Packagist

Messenger for Laravel masthead image.

Goal

To provide a drop-in, application-wide alerting functionality to display various types of alerts and notifications to the user in response to their actions.

Prerequisites

  • Bootstrap 3 or 4
  • Laravel 5.5 or 5.6
  • PHP >= 7.1.3

Features

  • Feedback notifications in form of bootstrap alerts or modals.
  • Send notifications from facade, app IoC reference, or blade directive.
  • Display notification easily via a blade command.

Installation

composer require genealabs/laravel-messenger

Nothing else needs to be done, as the service provider and facades will be auto-loaded.

Configuration

If you need to make changes to the default configuration, run the following command to publish the configuration file config\genealabs-laravel-messenger.php:

php artisan messenger:publish --config

After that you can configure the configuration according to your needs:

/*
|--------------------------------------------------------------------------
| CSS Framework Configuration
|--------------------------------------------------------------------------
|
| Here you may configure the CSS framework to be used by Messenger for
| Laravel. This allows you to switch or upgrade frameworks without
| having to recreate all your alerts.
|
| Available Settings: "bootstrap3", "bootstrap4"
|
*/

'framework' => 'bootstrap4',

/*
|--------------------------------------------------------------------------
| JavaScript Blade Section
|--------------------------------------------------------------------------
|
| Your layout blade template will need to have a section dedicated to
| inline JavaScript methods and commands that are injected by this
| package. This will eliminate conflicts with Vue, as well as
| making sure that JS is run after all deps are loaded.
|
*/

'javascript-blade-section' => 'js',

Usage

  1. Trigger an alert using either the facade/IoC helper, or a blade directive in another view:
// IoC helper:
app('messenger')->send('message', 'title', 'level', autoHide, 'framework');

// Facade:
Messenger::send('message', 'title', 'level', autoHide, 'framework');

// Blade directive:
@send ('message', 'title', 'level', autoHide, 'framework')
  1. Add the placeholder to your layout blade file:
<div class="container">

    @deliver

</div>

Parameters

message

string|required

The body of the message you want to deliver to your user. This may contain HTML. If you add links, be sure to add the appropriate classes for the framework you are using.

title

string | optional | default: ''

Title of the notification, will be inserted as an <h4> tag, can also include HTML. Again, keep in mind to add any framework-specific formatting yourself.

level

string | optional | default: 'info'

If provided, must be one of the following: 'info', 'success', 'warning', 'danger'.

autoHide

boolean | optional | default: false

Allows you to let the notification disappear automatically after 15 seconds. If autoHide is false, the user will be provided a close button in the alert.

framework

string | optional | default: 'bootstrap3'

Specify the framework you are using. Right now it only supports 'bootstrap3' or 'bootstrap4'.

type

string | optional | default: 'alert'

Invoke any of the available alert modes. Currently only supports 'alert' or 'modal'.

You can’t perform that action at this time.