LaravelPackages.net
Acme Inc.
Toggle sidebar
kapouet/laravel-notyf

Add Notyf support in your Laravel app

1.016
7
1.0.0
About kapouet/laravel-notyf

kapouet/laravel-notyf is a Laravel package for add notyf support in your laravel app. It currently has 7 GitHub stars and 1.016 downloads on Packagist (latest version 1.0.0). Install it with composer require kapouet/laravel-notyf. Discover more Laravel packages by kapouet or browse all Laravel packages to compare alternatives.

Last updated

Laravel Notyf banner

Latest Version on Packagist Total Downloads

Add Notyf support in your Laravel app.

Installation

You can install the package via composer

composer require kapouet/laravel-notyf

You can publish the config file with:

php artisan vendor:publish --provider="Kapouet\Notyf\NotyfServiceProvider" --tag="kapouet:config"

The config file is structured like Notyf, but in PHP, see https://github.com/caroso1222/notyf#api

Usage

Import assets

<!-- For CSS -->
<x-notyf::styles/>

<!-- For JS -->
<!-- Import this script after Livewire if you use it -->
<xnotyf::scripts/>

Send toast with PHP

Notyf::success('I\'m a success message');
Notyf::error('I\'m an error message');

// If you are added custom types in config file
// https://github.com/caroso1222/notyf#inotyfnotificationoptions
Notyf::message('custom', 'I\'m a custom message');

Send toast with Livewire

use Kapouet\Notyf\Traits\Livewire\WithNotyf;
use Livewire\Component;

class MyComponent extends Component
{
    use WithNotyf;
    
    public function render(): string
    {
        return <<<'blade'
            <div>
                <button wire:click="toast">Toast me</button>
            </div>
        blade;
    }
    
    public function toast(): void
    {
        $this->notyfSuccess('I\'m a success message');
        $this->notyfError('I\'m an error message');

        // If you are added custom types in config file
        // https://github.com/caroso1222/notyf#inotyfnotificationoptions
        $this->notyfMessage('custom', 'I\'m a custom message');
    }
}

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Star History Chart