How to redirect away from a Laravel Livewire page for confirmation and transfer data across
LivewireIn the good old days website development was pretty straightforward - you posted to a new page and showed a confirmation message. Or maybe you didn't need security so a simple get would have done the trick. When using Laravel livewire it's really useful to know how to redirect. It's also very clearly defined in the Laravel Livewire manual. The issue though is they don't really tell you how to get data across, probably because there's more than one way and it's more a question of general web development versus Livewire. But anyhow here we try to consolidate both concepts.
Redirecting A Laravel Livewire Page Without data
return redirect()->to('/contact-form-success');
Redirect a Laravel Page With data
If you want to send data with your redirect, remember conceptually you're not POSTing, but rather redirecting / GETting. So you have two options:
1. Redirecting using a URL parameter to get data across
Redirect::to('settings/photos?image_=' . $image_); lang-php
URL Parameter Reference:
2. Redirecting using a session variable to get data across
return Redirect::route('clients.show, $id')->with( ['data' => $data] ); lang-php
And then on the next page:
Session::get('data'); lang-php
Session Variable Reference: