PHP code example of kevsuarez / livewire-notiflix

1. Go to this page and download the library: Download kevsuarez/livewire-notiflix library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kevsuarez / livewire-notiflix example snippets


'providers' => [
    // ...
    Kevsuarez\LivewireNotiflix\LivewireNotiflixServiceProvider::class,
];

/*
* @param1 {String}: Optional, type text in String format.
*   -> Supported values:
*       • success
*       • info
*       • warning
*       • error
*       • failure
*    
*   -> Default value: 'success'
*
* @param2 {String}: Optional, message text in String format.
*   -> Default value: 'Message'
*
* @param3 {Array}: Optional, extend the initialize options with new options and the callback for each notification element.
*   -> Default value: []
*
* @param4 {Bool}: Optional, enable the callback that is triggered when the notification element has been clicked.
    -> Default value: false
*/

public function triggerNotify()
{
    $type        = 'success';
    $message     = 'Hello World!';
    $options     = [];
    $useCallback = false;

    $this->notify($type, $message, $options, $useCallback);
}

public function onNotifyClick()
{
    $this->notify(
        'success',
        'Thanks! consider giving it a star on github.',
    );
}

protected $listeners = [
    'onNotifyClick',
    ...
];

public function triggerNotify()
{
    $type        = 'info';
    $message     = 'Click Me';
    $options     = [];
    $useCallback = true;

    $this->notify($type, $message, $options, $useCallback);
}

/*
* @param1 {String}: Optional, type text in String format.
*   -> Supported values:
*       • success
*       • info
*       • warning
*       • error
*       • failure
*    
*   -> Default value: 'success'
*
* @param2 {String}: Optional, title text in String format.
*   -> Default value: 'Title'
*
* @param3 {String}: Optional, message text in String format.
*   -> Default value: 'Message'
*
* @param4 {String}: Optional, button text in String format.
*   -> Default value: 'Okay'
*
* @param5 {Array}: Optional, extend the initialize options with new options and the callback for each element.
*   -> Default value: []
*
* @param6 {Bool}: Optional, enable the callback that is triggered when the 'Okay' button has been clicked.
*   -> Default value: false
*/

public function triggerAlert()
{
    $type        = 'success';
    $title       = 'Success!';
    $message     = 'Place you success message here!';
    $buttonText  = 'Okay';
    $options     = [];
    $useCallback = false;

    $this->alert($type, $title, $message, $buttonText, $options, $useCallback);
}

public function onAlertClick()
{
    $this->alert(
        'success',
        'Good job!',
        'You clicked the button!.'
    );
}

protected $listeners = [
    'onAlertClick',
    ...
];

public function triggerAlert()
{
    $type        = 'info';
    $title       = 'Hi!';
    $message     = 'Press Ok button to continue.';
    $buttonText  = 'Ok';
    $options     = [];
    $useCallback = true;

    $this->alert($type, $title, $message, $buttonText, $options, $useCallback);
}

/*
* @param1 {String}: Optional, mode text in String format.
*   -> Supported values:
*       • notify
*       • alert
*
*   -> Default value: 'notify'
*
* @param2 {Array}: Optional, arguments in Array format.  
*   -> Supports all "notify or alert" arguments as an associative array.
*
*   -> Default value: All "notify" arguments as an associative array.
*/

public function triggerFlash()
{
    //Mode: notify 
    $this->flash('notify', [
        'type'        => 'success',
        'message'     => 'Hello World!',
        'options'     => [],
        'useCallback' => false,
    ]);

    //Or

    //Mode: alert
    $this->flash('alert', [
        'type'        => 'success',
        'title'       => 'Success!',
        'message'     => 'Place you success message here!',
        'buttonText'  => 'Okay',
        'options'     => [],
        'useCallback' => false,
    ]);
}

/*
* @param1 {String}: Optional, title text in String format.
*   -> Default value: 'Title'
*
* @param2 {String}: Optional, message text in String format.
*   -> Default value: 'Message'
*
* @param3 {String}: Optional, confirm button text in String format.
*   -> Default value: 'Confirm'
*
* @param4 {String}: Optional, cancel button text in String format.
*   -> Default value: 'Cancel'
*
* @param5 {Array}: Optional, extend the initialize options with new options and the callbacks for each confirm box.
*   -> Default value: []
*/

public function confirmed($params)
{
    $this->notify(
        'success',
        'Thanks! consider giving it a star on github.'
    );
}

public function cancelled()
{
    $this->notify(
        'info',
        'Understood',
    );
}

protected $listeners = [
    'onConfirmed' => 'confirmed',
    'onCancelled' => 'cancelled'
    ...
];

public function triggerConfirm()
{
    $title             = 'Livewire Notiflix';
    $message           = 'Do you love Livewire Notiflix?';
    $confirmButtonText = 'Yes';
    $cancelButtonText  = 'Nope';
    $options           = [
        'onConfirmed' => 'onConfirmed',
        'onCancelled' => 'onCancelled',

        //You can pass the value as an argument to the confirm method, if you want.
        'params'      => 'Thanks! for choose Livewire Notiflix.',
    ];

    $this->confirm($title, $message, $confirmButtonText, $cancelButtonText, $options);
}

/*
* @param1 {String}: Optional, title text in String format.
*   -> Default value: 'Title'
*
* @param2 {String}: Optional, question text in String format.
*   -> Default value: 'Question'
*
* @param3 {String}: Optional, answer text in String format.
*   -> Default value: 'Answer'
*
* @param4 {String}: Optional, answer button text in String format.
*   -> Default value: 'Answer'
*
* @param5 {String}: Optional, cancel button text in String format.
*   -> Default value: 'Cancel'
*
* @param6 {Array}: Optional, extend the initialize options with new options and the callbacks for each confirm box.
*   -> Default value: []
*/

public function onAskConfirmed($params)
{
    $this->notify(
        'success',
        'Thanks! consider giving it a star on github.'
    );
}

public function onAskCancelled()
{
    $this->notify(
        'info',
        'Understood',
    );
}

protected $listeners = [
    'onAskConfirmed',
    'onAskCancelled',
    ...
];

public function triggerAsk()
{
    $title             = 'Livewire Notiflix';
    $question          = 'Do you love Livewire Notiflix?';
    $answer            = 'Yes';
    $answerButtonText  = 'Answer';
    $cancelButtonText  = 'Cancel';
    $options           = [
        'onAskConfirmed' => 'onAskConfirmed',
        'onAskCancelled' => 'onAskCancelled',

        //You can pass the value as an argument to the onAskConfirmed method, if you want.
        'params'         => 'Thanks! for choose Livewire Notiflix.',
    ];

    $this->ask($title, $question, $answer, $answerButtonText, $cancelButtonText, $options);
}
bash
php artisan vendor:publish --provider="Kevsuarez\LivewireNotiflix\LivewireNotiflixServiceProvider" --tag="config"