PHP code example of afrizalmy / laratoast-jquery

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

    

afrizalmy / laratoast-jquery example snippets


'providers' => [
    ...
    Afrizalmy\Laratoast\LaratoastServiceProvider::class
    ...
];

// Display an info toast
laratoast()->info("Are you married?","Information","bottom-right");



namespace App\Http\Controllers;

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

class PostController extends Controller
{
    public function store(PostRequest $request)
    {
        $post = Post::create($request->only(['title', 'body']));

        if ($post instanceof Model) {
            laratoast()->success("Data has been saved successfully!","Success","bottom-right",['textAlign'=>'left']);

            return redirect()->route('posts.index');
        }
        laratoast()->error("An error has occurred please try again later.","Error!","bottom-center");

        return back();
    }
}

// laratoast()->success("Message","Title","position", "options"); 
laratoast()->success("Success notification test","Success","bottom-left"); 
// laratoast()->error("Message","Title","position", "options"); 
laratoast()->error("Error notification test","Error","bottom-right",['textAlign'=>'center']);
// laratoast()->warning("Message","Title","position", "options");       
laratoast()->warning("Warning notification test","Warning","bottom-center",['textAlign'=>'right']); 
// laratoast()->info("Message","Title","position", "options"); 
laratoast()->info("Info notification test","Info","top-left",['textAlign'=>'left']);
 
sh
php artisan vendor:publish --provider='Afrizalmy\Laratoast\LaratoastServiceProvider'