inertia
🚀
laravel
🚀
Inertia and redicting back to save state
Just a reminder to self that when I have multiple forms or components on a page and I want a component to send a backend request and not lose state I just do this in the controller.
public function detachFaceBookDataFromLike(FacebookLike $facebookLike) {
$validate = request()->validate([
'ids' => ['required', 'array']
]);
$facebookLike->facebook_data()->detach($validate['ids']);
request()->session()->flash('flash.banner', 'Updated');
return back();
}
Then it will show the message (this is thanks to JetStream) and it will preserve the state I care about like a filter in the url (query string) etc