- PHP 8.0 and up
- Laravel 8 and up
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