I continue to work with HTMX.
Should I redefine RedirectResponse(back(), route(), to()) and update redirect()?
$responseHTMX = single_service('redirectresponse')
->hxRedirect((string) previous_url(true))
->with(...$flashes)
;
$responseCI = redirect()->back()->with(...$flashes);
When the request came as HTMX, the redirect will have the initial headers. By making a regular redirect, the response will remain as for HTMX. Therefore, the second entry does not make sense.
Now we need to duplicate the code for different cases (HTMX or a regular request). Would it be better to combine these conditions inside the new functions?
I continue to work with HTMX.
Should I redefine
RedirectResponse(back(), route(), to()) and updateredirect()?When the request came as HTMX, the redirect will have the initial headers. By making a regular redirect, the response will remain as for HTMX. Therefore, the second entry does not make sense.
Now we need to duplicate the code for different cases (HTMX or a regular request). Would it be better to combine these conditions inside the new functions?