Skip to content

FlashData not working #815

@alexgomez88

Description

@alexgomez88

PHP package version

2.x-dev

Inertia adapter(s) affected (if any)

  • React
  • Vue 3
  • Svelte
  • Not Applicable

Backend stack

Laravel 12
PHP 8.2

Describe the problem

I have a simple route that do:

  Route::post('/', function (InstallRequest $request) {

       Artisan::call('migrate:fresh --seed');

       return Inertia::flash('toast', [
           'message' => 'Database installed successfully',
       ])->back();
       
   })->name('send');

I tried to get flash messager by many ways. (usePage hook, global event) and i'm not getting any network answer.

Steps to reproduce

post(route('install.send'), {
            onFlash: ({ toast }) => {
                console.log('Toast:', toast)
                // toast = { message: 'Database installed successfully' } 
            },
            onFinish: () => {
                //reset('password', 'password_confirmation')
            },
        });

and

useEffect(() => {
        const removeSuccess = router.on('success', (event) => {
            console.log('Success event:', event.detail.page)
        })

        const removeFlash = router.on('flash', (event) => {
            console.log('Flash event:', event.detail.flash)
        })

        return () => {
            removeSuccess()
            removeFlash()
        }
    }, [])

I get success but not flash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs more info/workNeeds more info from the author or additional work to get merged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions