digitlimit / alert by digitlimit

An easy way of flashing messages in Laravel Application
288
28
2
Package Data
Maintainer Username: digitlimit
Maintainer Contact: frankemeks77@yahoo.com (Emeka Mbah)
Package Create Date: 2015-02-19
Package Last Update: 2024-01-07
Home Page: https://github.com/digitlimit/alert/wiki
Language: PHP
License: MIT
Last Refreshed: 2024-04-17 15:00:13
Package Statistics
Total Downloads: 288
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 28
Total Watchers: 2
Total Forks: 3
Total Open Issues: 2

Alert

Join the chat at https://gitter.im/digitlimit/alert Alert is designed to make flashing messages in Laravel Applications a breeze. Tested and works in Laravel 5 or less

For this to work you need to include Twitter Bootstrap in your page

Installation

Add alert in your composer.json file:

"require": {
    "digitlimit/alert": "v1.0"
}

Then run

composer update

In Laravel 5 include Alert Service Provider within config/app.php or app/config/app.php in Laravel 4

'providers' => [
    'Digitlimit\Alert\AlertServiceProvider'
];

You can also include alert facade in aliases array in same file above i.e config/app.php or app/config/app.php in Laravel 4

'aliases' => [
    'Alert'     => 'Digitlimit\Alert\Facades\Alert'
];

Usage

In your controller simply set your alert before redirection like so:

In laravel 5 controller for example:

<?php namespace App\Http\Controllers;

use \Alert; //using Alert Facades

class UserController extends Controller
{
  public function postRegister(UserRegisterRequest $request)
  {
      Alert::form('Your account was successfully created','Congratulations')->success()->closable()->showIcon();
        
      return redirect()->route('users.getRegister');
   }
}

Then in your view your can include the flash message to your view like so:

<div class"registration_form">

    @include('alert::form')
    
    <form method="POST" action="{{route('users.postRegister')}}" novalidate>
            <div class="form-group">
                <label for="name">First Name</label>
                <input type="text" id="first_name" class="form-control" name="first_name" placeholder="First Name">
            </div>
            <div class="form-group">
                <label for="email">Email</label>
                <input type="email" id="email" class="form-control" name="email" placeholder="Email Address">
            </div>
            <div class="form-group">
                <label for="password">Password</label>
                <input type="password" id="password" class="form-control" name="password">
            </div>
            <button type="submit" class="btn btn-success">Register</button>
        </form>
</div>
Form Alert Example

alert

Features

There are basically three types of alert messages you can flash

Form - used mostly to display message in the header of your form

Some where in the controller:

//This simply displays a success message
Alert::form('Your account was successfully created','Congratulations')->success();

Some where in the view:

@include('alert::form')

Notify - used mostly on the header of your page

Some where in the controller:

//This simply displays a success message
Alert::notify('Your account is going to expire today.','Info')->info();

Some where in the view layout where you want the alert to appear:

@include('alert::notify')

Modal - used mostly to display an overlay message

Some where in the controller:

//This simply displays a success message
Alert::modal('Thanks for joining us.','Title')->info();

Some where in the view layout:

@include('alert::modal')