Skip to content

itsnubix/toast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nubix Toast Notification for Laravel Application with Breeze and Vue

Requirements

  • PHP 8.0 and up
  • Laravel 8 and up

Installation

Step 1. Install dev package with Composer

composer require itsnubix/toast
php artisan nubix-toast:install

Step 2. Add follow lines to resources/js/app.js file.

  • Add follow import to the top of the file
import toastPlugin from '@/Plugins/toast'
  • Add following line after .use(plugin)
.use(toastPlugin)

Step 3. Add following code to share() in HandleInertiaRequests.php

'toast' => fn () => $request->session()->get(config('toast.session_id')) ?? []

Final share function should look like this.

/**
 * Define the props that are shared by default.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return array
 */
public function share(Request $request)
{
    return array_merge(parent::share($request), [
        'auth' => [
            'user' => $request->user(),
        ],
        'toast' => fn () => $request->session()->get(config('toast.session_id')) ?? []
    ]);
}

Step 4. Finish up installation

npm install && npm run dev