• Stars
    star
    448
  • Rank 97,523 (Top 2 %)
  • Language
    PHP
  • Created almost 9 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Easy flash notifications https://packagist.org/packages/mercuryseries/flashy

Easy Flash Messages

Example of Error Notification

Copyright

Inspired by Jeffrey Way's Flash Package. Added following Jeffrey Ωmega's request.

Installation

Video Tutorial

Watch a Video Tutorial here

You like text ?

First, pull in the package through Composer.

Run composer require mercuryseries/flashy

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

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

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

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

Usage

Within your controllers, before you perform a redirect...

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

    return Redirect::home();
}

You may also do:

  • 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:

  • '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:

/**
 * 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');.

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

@if(Session::has('flashy_notification.message'))
<script id="flashy-template" type="text/template">
    <div class="flashy flashy--{{ Session::get('flashy_notification.type') }}">
        <i class="material-icons">speaker_notes</i>
        <a href="#" class="flashy__body" target="_blank"></a>
    </div>
</script>

<script>
    flashy("{{ Session::get('flashy_notification.message') }}", "{{ Session::get('flashy_notification.link') }}");
</script>
@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:

@include('flashy::message')

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

Example

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

<div class="container">

    <p>Welcome to my website...</p>
</div>

<script src="//code.jquery.com/jquery.js"></script>
@include('flashy::message')
</body>
</html>

If you need to modify the flash message partials, you can run:

php artisan vendor:publish

The two package views will now be located in the app/views/packages/mercuryseries/flashy/ directory.

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:

<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:

<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>

<script id="flashy-template" type="text/template">
    <div class="flashy flashy--{{ Session::get('flashy_notification.type') }}">
        <i class="material-icons">speaker_notes</i>
        <a href="#" class="flashy__body" target="_blank"></a>
    </div>
</script>

More Repositories

1

laravel-helpers

Dynamic Laravel Method Helpers
PHP
33
star
2

flashy-bundle

Nice flash notifications https://packagist.org/packages/mercuryseries/flashy-bundle
PHP
29
star
3

laravel-elixir-minify-html

Minify the HTML that gets generated by your Blade template files or just static HTML files with Laravel Elixir.
JavaScript
20
star
4

laracarte

A kind of Laramap (laramap.com) Clone
PHP
20
star
5

pinboard

Pinterest Clone App Built With Laravel
PHP
17
star
6

pagination-php

Système de pagination en PHP
PHP
8
star
7

flask-from-zero-to-zoro

Tutorial Flask: From Zero to Zoro
HTML
8
star
8

dynamic-select-symfony

PHP
8
star
9

panterest

Clone de Pinterest avec Symfony 5
PHP
8
star
10

demo-turbo

PHP
7
star
11

config-mail-local

Configuration pour l'envoi de mail en local sous WAMP et XAMPP
6
star
12

skeleton-screen-loading-livewire

Skeleton Screen Livewire
PHP
6
star
13

inertia-bundle

Enhanced Symfony adapter for Inertia.js.
PHP
6
star
14

inertia.symfony.react

Shell
5
star
15

django-inertia-vue

Python
5
star
16

embed-demo

PHP
4
star
17

hello-city-laravel

Laravel application that displays the current time in your city.
PHP
4
star
18

hello-turbo

PHP
4
star
19

tinder

Tinder - Tutoriel CSS PAR LA PRATIQUE
CSS
3
star
20

laracarte-tdn

Laracarte Tutoriel TDN
PHP
3
star
21

react-europe

React Europe - Tutoriel CSS PAR LA PRATIQUE
CSS
3
star
22

track-videojs-play

VideoJS Time Tracker with possibility to pick up where we last left off.
JavaScript
3
star
23

java-excel-mysql

Récupération de données depuis un fichier Excel puis insertion dans une base de données
Java
2
star
24

demo-symfony-phonenumbers

PHP
2
star
25

demo-tailwind-forms

PHP
2
star
26

inscription-ajax

Système d'inscription en AJAX
PHP
2
star
27

mercuryseries.github.io

My Github Page
HTML
2
star
28

laravel-youtube-tutorial-evenbrote

Eventbrote Project
PHP
2
star
29

barre-de-progression-dynamique

Barre de progression dynamique
PHP
2
star
30

tdn-podcast

Ambiance à la TDN!
PHP
2
star
31

selz

Selz - Tutoriel CSS PAR LA PRATIQUE
CSS
2
star
32

eventbrote-symfony-5

PHP
1
star
33

Security-keys-CakePHP

Generating Security keys for CakePHP Framework
PHP
1
star
34

demo-tailwind-symfony

PHP
1
star
35

search-engine

Moteur de recherche pour site web
PHP
1
star
36

inertia-bundle-recipe

1
star
37

scroll-infini

Scroll Infini (Like Facebook & Twitter)
PHP
1
star
38

Slider-Simple

Creating a small slider with scroll managed by the user. (written in HTML5/CSS3/JS).
1
star
39

demo-netlify

Demo Netlify
HTML
1
star
40

pays-utilisateur-geolocalisation

Géolocalisation utilisateurs
PHP
1
star
41

demo-postcss

HTML
1
star
42

config-php5.6

Configuration php.ini pour la version PHP 5.6.6
1
star
43

Capture-Video

Capture images via user's webcam with the ability to apply some changes to this images (grayscale conversion, Inverting colors ...) and also transfer them to a server.
PHP
1
star