Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Prido's avatar
Level 2

Laravel api prompt user logic

I have laravel api with passport for auth. I also have angular app that relies on this api. Now i send data to store in db as json and everything is fine at this point. Now wen api receives data it then do some logic then prompt user to save or abort based on the state of the output of the logic we run in api. How can i do that? Such that if api prompts user we then send back answer to api wen user answers and continue operation

0 likes
1 reply
martinbean's avatar

@prido What logic? Give us the use case.

What you’re describing sounds like dealing with conflicts (i.e. the data was changed in between the user requesting a resource and then updating it). In which case, this isn’t a Passport issue and HTTP headers exist for this exact scenario (search for “Lost update problem” in a search engine).

If the record has been updated on the server in between the user loading it and then submitting updates, your API should return a 409 Conflict response. Your Angular app (or any consumer of your API) can then take this to mean the resource has since been modified, and your Angular app can then do any logic of presenting a UI option to allow the user to either overwrite the record on the server with their changes, or abort the operation.

Please or to participate in this conversation.