You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a scenario where I want to provide additional information but only for a call to a special route. The controller behind that route does some processing and I want to get the result of that processing in the frontend.
Lets say I have the following controller:
class MyController {
publicfunctionshow()
{
returninertia('Page', [
'someProp' => 'someValue'
]);
}
publicfunctionprocess()
{
$result = 1 + 1;
// How do I get the result merged into the props?returnback();
}
}
(The problem in the example could be solved with lazy props. The actual problem requires input parameters and has way more code so its not something that would belong into a Closure of Inertia::lazy)
When using router.post inertia does two requests. One for the actual post request, then another one to the show endpoint. So returning the result in the process function doesn't seem to work.
I have thought (and read) about storing it in the session, then extracting it in the HandleInertiaRequests middleware, however that would result in a race condition when multiple requests to the show endpoint happen at the same time.
I also cannot use render again, since the endpoint can be called from two different views.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have a scenario where I want to provide additional information but only for a call to a special route. The controller behind that route does some processing and I want to get the result of that processing in the frontend.
Lets say I have the following controller:
(The problem in the example could be solved with lazy props. The actual problem requires input parameters and has way more code so its not something that would belong into a Closure of
Inertia::lazy
)When using
router.post
inertia does two requests. One for the actual post request, then another one to theshow
endpoint. So returning the result in theprocess
function doesn't seem to work.I have thought (and read) about storing it in the session, then extracting it in the
HandleInertiaRequests
middleware, however that would result in a race condition when multiple requests to theshow
endpoint happen at the same time.I also cannot use
render
again, since the endpoint can be called from two different views.Is there any way this is doable with Inertia?
Beta Was this translation helpful? Give feedback.
All reactions