doctrine/mongodb-odm-softdelete-bundle
deletedAt field) is a well-established pattern in Laravel (via SoftDeletes trait in Eloquent). However, the implementation is ODM-specific, requiring MongoDB integration.SoftDeletes for SQL databases.appKernel.php, deps file) are incompatible with Laravel’s composer.json and config/app.php.Criteria, QueryBuilder) differs from Eloquent, requiring rewrites.deleting model events).model events, query caching).SoftDeletes) suffice?SoftDeletes or custom MongoDB soft-delete logic been considered?spatie/laravel-mongodb) that support soft deletes?deps).Bundle, Kernel) cannot be directly ported to Laravel.SoftDeleteable trait) and adapt it for Laravel’s MongoDB driver (e.g., jenssegers/mongodb).use Jenssegers\Mongodb\Eloquent\Model as MongoModel;
class Post extends MongoModel {
use \Doctrine\ODM\MongoDB\SoftDelete\SoftDeleteable; // Hypothetical port
protected $deletedField = 'deleted_at';
}
$natural or $currentDate operators in queries.| Step | Action | Tools/Dependencies | Risk |
|---|---|---|---|
| 1 | Assess MongoDB Need | Evaluate if SQL SoftDeletes or hybrid architecture suffices. |
Low |
| 2 | Choose Integration Strategy | Decide between microservice, custom wrapper, or feature parity. | Medium |
| 3 | Extract Core Logic | Isolate SoftDeleteable trait from the bundle (if possible). |
High (reverse-engineering) |
| 4 | Adapt for Laravel | Rewrite for jenssegers/mongodb or Laravel’s service container. |
High |
| 5 | Test Edge Cases | Verify soft-deletes in queries, relationships, and events. | Medium |
| 6 | Fallback Plan | Document hard-delete procedures if soft-delete fails. | Low |
jenssegers/mongodb uses PHP MongoDB driver, while ODM uses Doctrine’s MongoDB client. Query syntax may differ.EventDispatcher, which Laravel replaces with its own system.jenssegers/mongodb + custom logic (no bundle).Post::whereNull('deleted_at')->get(); // Active records
Bundle with a Laravel Service Provider.deleted_at.whereNull('deleted_at') to every query increases indexing requirements on deleted_at.post:{{id}}:deleted).| Scenario | Impact | Mitigation |
|---|---|---|
| Bundle Dependency Fails | Breaks soft-delete logic. | Fallback to hard deletes or custom logic. |
| Doctrine ODM Bug | Corrupts MongoDB data. | Regular backups; avoid ODM for critical paths. |
| PHP Version Conflict | Integration fails to load. | Use Docker to isolate PHP versions. |
| Query Performance Degradation | Slow API responses. | Optimize ` |
How can I help you explore Laravel packages today?