PHP code example of mujhtech / nav-toastr

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

    

mujhtech / nav-toastr example snippets


'providers' => [
    ...
    Mujhtech\NavToastr\NavToastrServiceProvider::class
    ...
];

// Display an info toast with no title
navtoastr()->info('Are you the 6 fingered man?')



namespace App\Http\Controllers;

use App\User;
use App\Http\Requests\PostRequest;
use Illuminate\Database\Eloquent\Model;

class UserController extends Controller
{
    public function store(UserRequest $request)
    {
        $post = User::create($request->only(['username', 'password']));

        if ($post instanceof Model) {

            navtoastr()->success('Data has been saved successfully!');

            return navtoastr()->named('posts.index');
        }

        navtoastr()->error('An error has occurred please try again later.');

        return navtoastr()->back();
    }
}

// Set a info toast
navtoastr()->info('My name is Muhideen Mujeeb')

// Set a success toast
navtoastr()->success('Have fun storming the castle!')

// Set an error toast
navtoastr()->error('I do not think that word means what you think it means.')

// Set an warning toast

navtoastr()->warning('We do have the Kapua suite available.')

navtoastr()->info('Are you the 6 fingered man?')->success('Have fun storming the castle!')->warning('doritos');
 
navtoastr()->render() or app('nav-toastr')->render()

function toastr(string $message = null, string $type = 'success', string $title = '', bool $enableCustomButton = false);

// config/nav-toastr.php


return [
    
    'custombuttons' => [
        [
            'text'      => 'Refresh the page',
            'reload'    => true
        ],
        [
            'text'      => 'My Website',
            'url'       => 'https://mujh.tech'
        ],
        [
            'text'      => 'Twitter',
            'url'       => 'https://twitter.com/mujhtech'
        ]
    ],
];
sh
$ php artisan navtoastr:install"