Framework RecipesImplementation, failure path, check

Laravel: preserve requirements through advanced agent edits

Work through PHP examples of real application boundaries: Dispatch Laravel order jobs only after the transaction commits; Use a conditional Laravel update to prevent overselling. Each recipe includes implementation code, integration prerequisites, failure-path tests to add, a Perch rule, and the captured broken/fixed source checks.

Download the Laravel rule pack ZIP · Inspect the YAML rules

PHP

Dispatch Laravel order jobs only after the transaction commits

A worker can pick up a queued job before the order transaction commits. Deferring dispatch prevents that race and discards dispatch when the transaction rolls back. It still leaves a durability question between committing state and successfully enqueuing a job.

Broken edit flagged · corrected edit passes

PHP

Use a conditional Laravel update to prevent overselling

Two requests can both pass a separate availability read. The conditional decrement lets the database decide against the current row when it performs the write. A unique tenant/SKU row and a nonnegative database constraint provide additional enforcement.

Broken edit flagged · corrected edit passes

Introductory framework example

Use a correction as a saved requirement

Choose the failure you need to prevent, add the scoped rule to your repository, and check both the broken and corrected implementation. Ask your agent to inspect the finding, repair the code and recheck the same rule. Keep framework tests beside the model check.

Perch keeps the requirement beside the code. Reuse the named check during the agent’s next edit and in CI, with cached answers free on unchanged requests.

Official Laravel documentation · All language and framework recipes