Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x-splade-flash doesn't show Flash-Data #555

Open
p4rad0xus opened this issue Mar 15, 2024 · 1 comment
Open

x-splade-flash doesn't show Flash-Data #555

p4rad0xus opened this issue Mar 15, 2024 · 1 comment

Comments

@p4rad0xus
Copy link

  • Laravel Version: 10.46.0
  • PHP Version: 8.3.2
  • Splade JS Version (npm): 1.4.16
  • Splade PHP Version (composer): 1.4.16
  • Dev environment (OS, Sail/Valet/etc): Herd

Description:

On a Blade-Plage I want to show a Flash-Message after submitting a form. To do this I use the x-splade-flash component and generate in the controller the flash data. The form is a x-splade-form component and there I want to use the some options like stay, reset-on-success and @success.

If I don't use the option stay it shows me only the flash data over the session() method.
If I use the option stay in the form component neither the x-splade-flash component nor the session() method shows the data.

Steps To Reproduce Issue:

My Blade-File

<x-splade-flash>
    <p v-if="flash.has('message')" v-text="flash.message" />
</x-splade-flash>

@if(session('message'))
    <div class="alert alert-success">
        {{ session('message') }}
     </div>
@endif

<x-splade-form action="{{ route('information.store') }}"
                            stay
                            reset-on-success
                            @success="$splade.emit('information-added')">
   ....
   <x-splade-submit label="Submit" />
</x-splade-form>

<x-splade-rehydrate on="information-added">
    <x-splade-table :for="$informations">
        ...
     </x-splade-table>
</x-splade-rehydrate>

My Controller - store-Method

public function store(Request $request)
{
        ....

        $request->session()->flash('message', "Some data");

        return redirect($request->getRequestUri());
}
@dusp2k
Copy link

dusp2k commented Mar 17, 2024

It seems to be working if you save the session manually.

public function store(Request $request): RedirectResponse
{
        ....

        $request->session()->flash('message', "Some data");
        $request->session()->save();

        return back();
}

You can also use a Toast:

Toast::success('Saved successfully!');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants