testmonitor/eloquent-incrementable
AUTO_INCREMENT) is insufficient. Fits Laravel’s Eloquent ORM natively.PROJ-001).project_id), enabling isolated sequences per segment—critical for shared-table architectures (e.g., SaaS apps with project-specific IDs).increment()/decrement() methods but extends them with pre-save hooks for dynamic logic (e.g., validation, formatting).creating, saved).SEQUENCE in PostgreSQL).code). Existing id (auto-increment) remains untouched.select-for-update).DB::transaction(), but requires explicit implementation.MAX(code) + 1 in a single query).INV-2025-001) add complexity (validation, parsing).project_id) or dynamic (e.g., user-defined scopes)? Does the package support nested groups?ModelEvents), and service providers. No framework modifications needed.SEQUENCE).TestTicket).composer.json and publish the service provider.Incrementable trait.code).auto-increment from id if using custom IDs entirely).Model event changes).creating events).ramsey/uuid).creating event → run custom increment logic → save.project_id changes, reset the counter for the new group.DB::transaction(function () use ($model) {
$model->code = $model->getNextIncrement();
$model->save();
});
debug("Generated code {$model->code} for group {$group}")).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Race condition (duplicate IDs) | Data integrity issues | Database transactions + retries |
| Database outage | ID generation fails | Fallback to UUIDs or manual IDs |
| PHP logic error | Invalid codes (e.g., null, 0) |
Validation + rollback |
| Group change not detected | Counter not reset | Audit logs + manual verification |
| High load | Timeouts or performance degradation | Queue jobs + caching |
How can I help you explore Laravel packages today?