Code Monkey home page Code Monkey logo

laravel-notification's Introduction

Notification

Flash notification that accepts a array and string. You can use it from your controller and also in the views.

Install

composer require intothesource/notification

After install

ServiceProvider

Add the following line to config/app.php.

at providers:

IntoTheSource\Notification\NotificationServiceProvider::class,

And at aliases:

'NotifyMessage' => IntoTheSource\Notification\Facade\NotifyMessage::class,

Publish files

Run the following command:

php artisan vendor:publish

Usage

Including the flash message in your view

To see the flash notification(s), you need to add the following @include().

@include('notification::message')

And if you want the basic styling that comes with the package, also inlcude the following lines:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="{{ asset('assets/css/notification-style.css') }}">

And the javascript:

<script src="{{ asset('assets/js/notification.js') }}"></script>
NOTE: You also need the jQuery library.

Usage from the Controller

available functions

Creating a notification can be done with the next commands:

Notification::
    - success()
    - error()
    - warning()
    - info()
    - overlay() // Bootstrap modal

You can also add the class "Important" to the alert message, with the following command:

Notification::error('message', 'title')->important();

Message variables

You can send a message as a string or as a array.

Syntax:

Notification::success([
                    'First success',
                    'Second success title' => [
                        'First success',
                        'Second success'
                    ],
                    'Third success'
                ]);

Notification::success('First success');

Title

The last string is the title. You have two options: give a string or leave it blank.

With title:

Notification::success('First success', 'Title success block');

Without title:

Notification::success('First success');

Overlay function

When you want to use a Modal from bootstrap you can do so with the following function and syntax:

Notification::overlay( 'Message', 'Title' );
NOTE: All the given variables need to be a string.

Usage from the view

You can also create a notification from the view file, this is usefull when your using a ajax form.

available functions

Creating a notification can be done with the next commands:

Notification.
    - success()
    - error()
    - warning()
    - info()
    - overlay() // Bootstrap modal

Messages, Title and Important

You can send a message as a string or as a array.

NOTE: The overlay function only accepts strings.

Messages

The following syntax is used at all functions but NOT FOR: .overlay():

Single message:

Notification.success( 'First message' );

Multiple single messages:

Notification.success( ['First message', 'Second message', 'Third message'] );

Grouping messages:

Notification.success( {'Third message with array': ['First message', 'Second message']} );

Grouping messages inside a Array of messages:

Notification.success( ['First message', 'Second message', {'Third message with array': ['First message', 'Second message']}] );

Title

Adding a title to a notification:

Notification.success( 'message', 'The Title goes after the message' );

Important

Adding the class important to your notification is easly done with adding a boolean as last variable:

Notification.success( 'message', 'Title', TRUE );

Overlay function

When you want to use a Modal from bootstrap you can do so with the following function and syntax:

Notification.overlay( 'Message', 'Title', 'Button text' );
NOTE: All the given variables need to be a string.

laravel-notification's People

Contributors

bbredewold avatar gjroke avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.