itsnubix/toast

0.0.2 2021-07-15 22:53 UTC

This package is not auto-updated.

Last update: 2024-05-18 07:05:41 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