zachflower/eloquent-interactions
Add likes, favorites, bookmarks, and other interactions to any Eloquent model in Laravel. A flexible trait-based package for recording user interactions with clean polymorphic relationships, reusable query scopes, and simple APIs.
Start by confirming your application is on Laravel 7–10 and PHP version compatible with the package. v1.0.0 is primarily a compatibility/stabilization major release; the release notes do not advertise new features, so treat it as the first stable baseline for supported Laravel versions.
Minimal path:
composer require zachflower/eloquent-interactions:^1.0.vendor:publish, then inspect the published config and migration before running php artisan migrate.User, and to the target model, typically something like Post.If upgrading from 0.2.0, pin ^1.0, clear config/cache, run the full test suite, and check for breaking changes even though the changelog is sparse.
Treat interactions as domain records rather than ad hoc controller logic. Put create/remove/toggle behavior behind a small action or service class, and authorize it with Laravel policies before writing.
Common patterns:
like, favorite, or bookmark.withCount-style queries for lists to avoid N+1 queries.RefreshDatabase and factories to create actors, targets, and interaction records explicitly.A practical first implementation is a “like” feature on posts: trait on User, trait on Post, a policy check, a unique index, a toggle endpoint, and a feature test covering duplicate likes and count changes.
php artisan config:clear and, in deployment, rebuild caches deliberately.How can I help you explore Laravel packages today?