- How do I install laravel-interaction/interactions in a Laravel app?
- Install it with Composer using composer require laravel-interaction/interactions. Publish and run the package migration to create the interactions table, then add the provided trait to the Eloquent models that should participate. There is no service provider configuration of consequence, no external services, and no credentials or queue requirements.
- Which Laravel and PHP versions does laravel-interaction/interactions support?
- Version 3.5.0 widens support for Laravel 13 and PHP 8.5, and also adds PHPUnit 12 and updated orchestra/testbench constraints. Check the package composer constraints against your production runtime, not just your CI matrix. If your application is still on older Laravel or PHP versions, verify the constraint range before upgrading.
- How do I add likes, favorites, or bookmarks to an Eloquent model?
- Add the package trait to the models that should interact, and to the models that can be interacted with, then use the package API to attach an interaction type. Interactions are stored in a single interactions table through a polymorphic relationship. You choose which models participate, so you can start with User and Post and extend to other models later.
- Can I define custom interaction types beyond likes and follows?
- Yes. Interaction types are string-keyed, so you can register custom types such as reactions, saved items, or subscriptions alongside built-in examples like likes, favorites, votes, follows, and bookmarks. Complex engagement rules such as weighting, expiry, rate limits, and moderation live outside the package and must be implemented by your application.
- How do I prevent duplicate interactions from the same user?
- The package does not document a built-in uniqueness guarantee, so enforce it yourself with a unique index on the interactions table and use guarded writes such as firstOrCreate. Decide the uniqueness semantics on the pivot, such as one like per actor per model per type, before launch. This is usually the main implementation work when adopting the package.
- Can I query who interacted with a model and what a user interacted with?
- Yes. The package exposes polymorphic relationships so you can query the actors who interacted with a given model and the models a given actor interacted with. It works naturally with Eloquent scopes, API resources, policies, and broadcasting. This makes it suitable for social features such as follower lists, saved items, and reaction summaries.
- Is laravel-interaction/interactions safe to use in production?
- Release 3.5.0 is additive and low-risk, with forward-compatibility changes for Laravel 13, PHP 8.5, PHPUnit 12, and testbench. Most listed pull requests are Dependabot updates to GitHub Actions and the license year, with no documented breaking changes or API modifications. The main caution is single-maintainer concentration, which is acceptable for a leaf utility package but not for load-bearing infrastructure.
- Does laravel-interaction/interactions clean up interactions when a model is deleted?
- Cascade cleanup is not documented in the package overview, so do not assume it is automatic. Add foreign key cascade behavior where appropriate or run an explicit purge job for orphaned interaction rows. Test deletion paths for both actor and target models before relying on the package in production.
- Can laravel-interaction/interactions handle follows, subscriptions, and votes together?
- Yes. Likes, favorites, votes, follows, bookmarks, and subscriptions can all be modeled as interaction types in the same polymorphic table. That removes roughly a sprint of bespoke schema, trait, and query-scope work for products with engagement features. Keep the engagement model simple, because ranking weights, moderation states, and audit trails belong in your application.
- When should I build social interactions in-house instead of using this package?
- Build in-house when engagement is a first-class domain with feed ranking weights, moderation states, audit trails, or event-sourced engagement. The package is a domain-adjacent convenience layer, so its abstraction is likely too thin once complex rules enter scope. It is also a poor fit for multi-database or sharded setups, raw query-builder data layers, or architectures that write engagement through an event bus.