Giter Site home page Giter Site logo

laravel-notify's Introduction

Laravel Notify

Elegant notifications to laravel with Toastr or PNotify

alt text

Installation

  1. Either run composer require helmesvs/laravel-notify or add "helmesvs/laravel-notify" to the require key in composer.json and run composer install.
  2. Add Helmesvs\Notify\NotifyServiceProvider::class, to the providers key in config/app.php.
  3. Add 'Notify' => Helmesvs\Notify\Facades\Notify::class, to the aliases key in config/app.php.
  4. Run php artisan vendor:publish --provider="Helmesvs\Notify\NotifyServiceProvider" --tag="notify" to publish the config file.
  5. Include the output {!! Notify::render() !!} in your master view template.
  6. Optional: Modify the configuration file located in config/notify.php.

Usage

Call one of these methods in your controllers to insert a notification:

  • Notify::warning($message, $title = null, $options = []) - add a warning notification
  • Notify::error($message, $title = null, $options = []) - add an error notification
  • Notify::info($message, $title = null, $options = []) - add an info notification
  • Notify::success($message, $title = null, $options = []) - add a success notification
  • Notify::add($type: warning|error|info|success, $message, $title = null, $options = []) - add a notification
  • Notify::clear() - clear all current notification

Configuration

Open config/notify.php to adjust package configuration. If this file doesn't exist, run php artisan vendor:publish --provider="Helmesvs\Notify\NotifyServiceProvider" --tag="notify" to create the default configuration file.

General Options

'options' => [
        'lib' => 'toastr',
        'style' => 'custom'
]

Set 'lib' as toastr to use toastr.js or pnotify to use pnotify.js.

Set 'style' to 'custom' to use custom settings, or as 'default' to default library settings.

The style of notifications can be customized in public/vendor/Notify/style.css.

Options Toastr

'ToastrOptions' => [
        "closeButton" => false,
        "closeHtml" => '',
        "newestOnTop" => true,
        "progressBar" => false,
        ...
]

Options PNotify

'PNotifyOptions' => [
        'title_escape' => false,
        'text_escape' => false,
        'styling' => 'brighttheme',
        'addclass' => '', 
        ...
]

For a list of available options, see toastr.js' documentation and pnotify.js' documentation.

laravel-notify's People

Contributors

emtudo avatar enriqueplace avatar helmesvs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-notify's Issues

Problem render

Hello devs,

I have a problem in Laravel-Notify every time I render the page it appears the notification I made in another controller.
How can I solve this problem?

";" comes up with the "{!! Notify::render() !!}"

Good evening dev, Amazing package Great Job,

Problem : when i render Notify using this "{!! Notify::render() !!}", it shows this ";"
I resolved this by removing from Notify.php line no. 114 method name : scripts()
Here,
notify_bug

HTML entities message

why you use this str_replace("'", "\'", htmlentities($notification['title'])) with title but not use with messaages like this str_replace("'", "\'", htmlentities( $notification['message'])) ?
I have an issue when throw errors on try catch and show errors with Notify::error.
The messages: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'phone' at row 1 (SQ.....
and Notify cant render my messages, fixed it by use str_replace("'", "\'", htmlentities( $notification['message'])). on line 85, file Notify.php

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.