Coder Social home page Coder Social logo

codelover254 / laravel-notify Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mckenziearts/laravel-notify

1.0 0.0 0.0 2.06 MB

Flexible Flash notifications for Laravel

Home Page: https://notify.arthurmonney.me

License: Other

PHP 10.16% CSS 7.97% JavaScript 1.84% HTML 80.03%

laravel-notify's Introduction

StyleCI Build Status Total Downloads Latest Stable Version License

Introduction

Laravel Notify is a package that lets you add custom notifications to your project. A diverse range of notification design is available.

Version Guidance

Version Laravel version Status Branch Install
1.x 5.5, 5.6, 5.7, 6.0 EOL 1.0 composer require mckenziearts/laravel-notify 1.*
2.x >= 7.0 Latest 2.0 composer require mckenziearts/laravel-notify

Android Version

If you need Android version please try this package Aesthetic Dialogs. Happy Coding ๐Ÿ‘จ๐Ÿพโ€๐Ÿ’ป

Installation

You can install the package using composer

$ composer require mckenziearts/laravel-notify

Then add the service provider to config/app.php. In Laravel versions 5.5 and beyond, this step can be skipped if package auto-discovery is enabled.

'providers' => [
    ...
    Mckenziearts\Notify\LaravelNotifyServiceProvider::class
    ...
];

You can publish the configuration file and assets by running:

$ php artisan vendor:publish --provider="Mckenziearts\Notify\LaravelNotifyServiceProvider"

Now that we have published a few new files to our application we need to reload them with the following command:

$ composer dump-autoload

Usage

  1. Add styles links with @notifyCss
  2. Add scripts links with @notifyJs
  3. use notify() helper function inside your controller to set a toast notification for info, success, warning or error
  4. Include notify partial to your master layout @include('notify::messages')

If you are on Laravel 7 or greater, you can use the tag syntax.

<x:notify-messages />

Basic

Within your controllers, before you perform a redirect call the notify method with a message.

public function store()
{
    notify()->success('Laravel Notify is awesome!');

    return Redirect::home();
}

An complete example:

<!doctype html>
<html>
    <head>
        <title>Laravel Notify</title>
        @notifyCss
    </head>
    <body>
        
        
        @include('notify::messages')
        // Laravel 7 or greater
        <x:notify-messages />
        @notifyJs
    </body>
</html>

Type of notifications

Laravel Notify actually display 5 types of notifications

  1. toast notification, who is default notification for Laravel Notify
notify()->success('Welcome to Laravel Notify โšก๏ธ') or notify()->success('Welcome to Laravel Notify โšก๏ธ', 'My custom title')
  1. connectify notification, example of basic usage
connectify('success', 'Connection Found', 'Success Message Here')
  1. drakify (๐Ÿ˜Ž) notification, only to display an alert
drakify('success') // for success alert 
or
drakify('error') // for error alert 
  1. smilify notification, a simple custom toast notification using smiley ๐Ÿ˜Š
smilify('success', 'You are successfully reconnected')
  1. emotify notification, a simple custom toast notification using vector emoticon
emotify('success', 'You are awesome, your data was successfully created')

Preset Notifications

If you have a specific notification that is used across multiple different places in your system, you can define it as a preset notification in your config file. This makes it easier to maintain commonly used notifications in one place. Read how to define preset messages in the Config section below.

As an example, to use a preset notification you have defined called 'common-notification', use the following:

notify()->preset('common-notification')

You can override any of the values that are set in the config if you need to. For example, this could be useful if you have a common notification across, but you want to change the icon in one particular place that it's used without having to manually write out a new notification.

To do this, simply pass in an array that has the key of the attribute that you want to override and the value you want to override it with.

As an example, we could override the 'title' of our 'common-notification' by using the following:

notify()->preset('common-notification', ['title' => 'This is the overridden title'])

Config

Config file are located at config/notify.php after publishing provider element.

Some awesome stuff. To active dark mode update the theme config, or add global variable NOTIFY_THEME on your .env file

'theme' => env('NOTIFY_THEME', 'dark'),

You can define preset notifications in the config file using the following structure:

'preset-messages' => [
    'user-updated' => [
        'message' => 'The user has been updated successfully.',
        'type'    => 'success',
        'model'   => 'connect',
        'title'   => 'User Updated',
    ],
    'user-deleted' => [
        'message' => 'The user has been deleted successfully.',
        'type'    => 'success',
        'model'   => 'connect',
        'title'   => 'User Deleted',
    ],
],

The example above shows the config for two preset notifications: 'user-updated' and 'user-deleted'.

Change log

Please see the changelog for more information on what has changed recently.

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email author email instead of using the issue tracker.

Credits

License

license. Please see the license file for more information.

laravel-notify's People

Contributors

mckenziearts avatar ash-jc-allen avatar ramonpego avatar

Stargazers

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