2017 © Pedro Peláez
 

library flashy

Easy flash notifications

image

mercuryseries/flashy

Easy flash notifications

  • Tuesday, October 10, 2017
  • by mercuryseries
  • Repository
  • 14 Watchers
  • 268 Stars
  • 12,601 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 29 Forks
  • 0 Open issues
  • 4 Versions
  • 14 % Grown

The README.md

Easy Flash Messages

Example of Error Notification, (*1)

Copyright

Inspired by Jeffrey Way's Flash Package. Added following Jeffrey Ωmega's request., (*2)

Installation

Video Tutorial

Watch a Video Tutorial here, (*3)

You like text ?

First, pull in the package through Composer., (*4)

Run composer require mercuryseries/flashy, (*5)

And then, if using Laravel 5, include the service provider within config/app.php., (*6)

'providers' => [
    MercurySeries\Flashy\FlashyServiceProvider::class,
];

And, for convenience, add a facade alias to this same file at the bottom:, (*7)

'aliases' => [
    'Flashy' => MercurySeries\Flashy\Flashy::class,
];

Usage

Within your controllers, before you perform a redirect..., (*8)

public function store()
{
    Flashy::message('Welcome Aboard!', 'http://your-awesome-link.com');

    return Redirect::home();
}

You may also do:, (*9)

  • Flashy::info('Message', 'http://your-awesome-link.com')
  • Flashy::success('Message', 'http://your-awesome-link.com')
  • Flashy::error('Message', 'http://your-awesome-link.com')
  • Flashy::warning('Message', 'http://your-awesome-link.com')
  • Flashy::primary('Message', 'http://your-awesome-link.com')
  • Flashy::primaryDark('Message', 'http://your-awesome-link.com')
  • Flashy::muted('Message', 'http://your-awesome-link.com')
  • Flashy::mutedDark('Message', 'http://your-awesome-link.com')

Again, if using Laravel, this will set a few keys in the session:, (*10)

  • 'flashy_notification.message' - The message you're flashing
  • 'flashy_notification.type' - A string that represents the type of notification (good for applying HTML class names)
  • 'flashy_notification.link' - The URL to redirect to on click

Alternatively, again, if you're using Laravel, you may reference the flashy() helper function, instead of the facade. Here's an example:, (*11)

/**
 * Destroy the user's session (logout).
 *
 * @return Response
 */
public function destroy()
{
    Auth::logout();

    flashy()->success('You have been logged out.', 'http://your-awesome-link.com');

    return home();
}

Or, for a general information flash, just do: flashy('Some message', 'http://your-awesome-link.com');., (*12)

With this message flashed to the session, you may now display it in your view(s). Maybe something like:, (*13)

@if(Session::has('flashy_notification.message'))











@endif

Because flash messages are so common, if you want, you may use (or modify) the views that are included with this package. Simply append to your layout view:, (*14)

@include('flashy::message')

Note that this package has jQuery has dependency. It's also better to load flashy before your body close tag., (*15)

Example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>



Welcome to my website..., (*16)

@include('flashy::message') </body> </html>

If you need to modify the flash message partials, you can run:, (*17)

php artisan vendor:publish

The two package views will now be located in the app/views/packages/mercuryseries/flashy/ directory., (*18)

Flashy::message('Welcome aboard!', 'http://your-awesome-link.com');

return Redirect::home();
Flashy::error('Sorry! Please try again.', 'http://your-awesome-link.com');

return Redirect::home();

Nice rendering

For a nice rendering you may include these lines in your head:, (*19)

<link href="//fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700' rel='stylesheet'>

and override the following sections of the default flashy view:, (*20)

<style type="text/css">
.flashy {
    font-family: "Source Sans Pro", Arial, sans-serif;
    padding: 11px 30px;
    border-radius: 4px;
    font-weight: 400;
    position: fixed;
    bottom: 20px;
    right: 20px;
    font-size: 16px;
    color: #fff;
}
</style>






The Versions

10/10 2017

dev-master

9999999-dev

Easy flash notifications

  Sources   Download

MIT

The Requires

 

The Development Requires

by Honore Hounwanou

10/10 2017

1.0.2

1.0.2.0

Easy flash notifications

  Sources   Download

MIT

The Requires

 

The Development Requires

by Honore Hounwanou

12/01 2016

1.0.1

1.0.1.0

Easy flash notifications

  Sources   Download

MIT

The Requires

 

The Development Requires

by Honore Hounwanou

12/01 2016

1.0.0

1.0.0.0

Easy flash notifications

  Sources   Download

MIT

The Requires

 

The Development Requires

by Honore Hounwanou