laravel-transactions-and-consistency
Originally fromnoartem/laravel-vue-skills
SKILL.md
Transactions and Consistency
Ensure multi-step changes are atomic; make retries safe.
Commands
DB::transaction(function () use ($order, $payload) {
$order->update([...]);
$order->items()->createMany($payload['items']);
OrderUpdated::dispatch($order); // or flag for after-commit
});
// Listener queued after commit
class SendInvoice implements ShouldQueue {
public $afterCommit = true;
}
Patterns
- Use
DB::transactionto wrap write sequences and related side-effects - Prefer
$afterCommitordispatchAfterCommit()for events / jobs - Make jobs idempotent (check existing state, use unique constraints)
- Use
lockForUpdate()for row-level coordination when needed - Validate invariants at the boundary before starting the transaction
Weekly Installs
11
Repository
noartem/skillsGitHub Stars
5
First Seen
Jan 30, 2026
Security Audits
Installed on
opencode10
cursor9
github-copilot8
codex8
kimi-cli8
gemini-cli8