itsnubix / toast
0.0.2
2021-07-15 22:53 UTC
Requires
- php: ^8.0
- illuminate/support: ^8.0
- inertiajs/inertia-laravel: ^0.4.1
This package is not auto-updated.
Last update: 2024-11-16 09:17:55 UTC
README
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