x-laravel/bookmarkable
x-laravel/bookmarkable adds bookmarking to Laravel Eloquent models with a simple trait. Let users save favorites or bookmarks on any model through polymorphic relations, with straightforward attach, detach, and toggle methods plus convenient per-user queries.
Bookmarked/Unbookmarked events mean you can measure adoption from day one rather than instrumenting later.CanBookmark / HasBookmarks) let you support multiple content types without a new join table per type, so the model decision stays reversible as the catalog grows.withBookmarkedBy() and isBookmarkedBy() solve the "show saved state on a list" problem in one query, which is usually the hidden cost that makes teams defer a bookmark feature.Adopt when:
withBookmarkedBy) without hand-rolling eager-loading logic.Look elsewhere or build in-house when:
Maturity note: v1.0.0 is the first stable release. That's good news for API stability and means no migration risk, but it also means limited field history — worth a spike and a dependency-pinning review before it sits on a critical path.
To executives: This is a small, low-risk dependency that gives us a standard "save for later" and collections capability in weeks rather than a quarter. It's a proven retention pattern in content-driven products, it ships with the measurement hooks (events) we need to judge whether it's working, and it handles its own data cleanup so there's no ongoing maintenance tax. Cost is a package dependency plus a short integration effort; the alternative is bespoke code we'd own forever.
To engineering: Two contracts and two traits, applied to the saver and the saveable models. Polymorphic, ULID-keyed folders, positional and last-activity ordering, a private default folder created lazily, and bookmark()/unbookmark()/hasBookmarked() across default, specific, or all folders. The saved-state-for-a-list problem is handled by a scope and a predicate, so no N+1. Events dispatch after commit, so listeners are safe. Deletion cascades and model:prune is wired into the scheduler with configurable frequency and chunk size. Connections, tables, models, and the default folder name are all publishable config, and messages ship in TR/EN. Integration surface is small; the main things we'd own are UI, permission rules for shared folders, and any count aggregation.
How can I help you explore Laravel packages today?