PHP code example of edvinaskrucas / notification

1. Go to this page and download the library: Download edvinaskrucas/notification 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/ */

    

edvinaskrucas / notification example snippets


\Krucas\Notification\NotificationServiceProvider::class,

\Krucas\Notification\Middleware\NotificationMiddleware::class,

\Krucas\Notification\Facades\Notification::success('Success message');
\Krucas\Notification\Facades\Notification::error('Error message');
\Krucas\Notification\Facades\Notification::info('Info message');
\Krucas\Notification\Facades\Notification::warning('Warning message');

\Krucas\Notification\Facades\Notification::container('myContainer', function($container)
{
    $container->info('Test info message');
    $container->error('Error');
});

\Krucas\Notification\Facades\Notification::container('myContainer')->info('Info message');

\Krucas\Notification\Facades\Notification::container('myContainer')->info('Info message')->error('Error message');

\Krucas\Notification\Facades\Notification::container()->info('Info message');

\Krucas\Notification\Facades\Notification::successInstant('Instant success message');

\Krucas\Notification\Facades\Notification::success('Success message', 'Custom format :message');

\Krucas\Notification\Facades\Notification::success(
    \Krucas\Notification\Facades\Notification::message('Sample text')
);

\Krucas\Notification\Facades\Notification::success(
    \Krucas\Notification\Facades\Notification::message('Sample text')->format(':message')
);

\Krucas\Notification\Facades\Notification::success(function (Message $message) {
    $message->setMessage('Sample text')->setPosition(1);
});

{!! \Krucas\Notification\Facades\Notification::container('myContainer')->get('success')->first() !!}

{!! \Krucas\Notification\Facades\Notification::container('myContainer')->all()->first() !!}

{!! \Krucas\Notification\Facades\Notification::showAll() !!}

{!! \Krucas\Notification\Facades\Notification::group('info', 'success', 'error', 'warning')->showAll() !!}

\Krucas\Notification\Facades\Notification::addToGrouping('success')->removeFromGrouping('error');

{!! \Krucas\Notification\Facades\Notification::showError() !!}
{!! \Krucas\Notification\Facades\Notification::showInfo() !!}
{!! \Krucas\Notification\Facades\Notification::showWarning() !!}
{!! \Krucas\Notification\Facades\Notification::showSuccess(':message') !!}

{!! \Krucas\Notification\Facades\Notification::container('myContainer')->showInfo(':message') !!}

@notification() // will render default container

@notification('custom') // will render 'custom' container

// This will add message at 5th position
\Krucas\Notification\Facades\Notification::info(Notification::message('info')->position(5));
\Krucas\Notification\Facades\Notification::info(Notification::message('info2')->position(1);

\Krucas\Notification\Facades\Notification::clearError();
\Krucas\Notification\Facades\Notification::clearWarning();
\Krucas\Notification\Facades\Notification::clearSuccess();
\Krucas\Notification\Facades\Notification::clearInfo();
\Krucas\Notification\Facades\Notification::clearAll();

{!! \Krucas\Notification\Facades\Notification::container('myInstant')
        ->infoInstant('Instant message added in a view and displayed!') !!}

{!! \Krucas\Notification\Facades\Notification::container('myInstant')
        ->infoInstant('Instant message added in a view and displayed!')
        ->errorInstant('Error...') !!}
app/config/app.php