- How do I install kilobyteno/laravel-user-guest-like in a Laravel application?
- Install the package with Composer using composer require kilobyteno/laravel-user-guest-like. Publish and run the package migrations so the likes table is created, then add the provided trait to any Eloquent model that should be likeable. In most Laravel apps the setup takes only a few minutes with no extra service configuration.
- Which Laravel versions does laravel-user-guest-like support?
- Version 1.5.0 adds support for Laravel 13 and drops Laravel 11, so it targets Laravel 12 and 13 applications. If your application is still on Laravel 11, pin the package to 1.4.x until you complete the framework upgrade. Always check the package composer constraints and PHP requirement before upgrading in production.
- How do guests like a model without logging in?
- The package tracks guest likes automatically, so anonymous visitors can use the same like and unlike methods as authenticated users. Guest identity is resolved and persisted by the package, typically through the session or a cookie-based identifier, with no additional setup required. You should still document how that identity behaves for your application and privacy requirements.
- How do I make an Eloquent model likeable?
- Add the package trait to the model that should receive likes, such as a Post or Comment model. After running the migrations, the model exposes simple methods for liking, unliking, and checking like status. You can apply the trait to multiple models because the package uses polymorphic relationships.
- How can I check whether a user or guest has already liked a model?
- Use the package helper methods on the likeable model to check the current actor's like status, such as hasLiked or an equivalent method. The same check works for authenticated users and guests because the package resolves the current actor automatically. This makes it straightforward to render the correct button state in Blade or an API response.
- Does the package prevent duplicate likes from the same user or guest?
- Duplicate prevention should be enforced at the database level with a unique constraint covering the likeable model, user ID, and guest identifier. The package provides the like and unlike methods, but you should verify the published migration and add indexes that match your access patterns. At scale, deliberate indexing and concurrency handling are important because like tables grow quickly.
- What happens to guest likes if a visitor clears cookies or changes browsers?
- Guest likes depend on the anonymous identifier the package stores, so clearing cookies or switching devices can make the visitor appear new and allow another like. This is an inherent limitation of anonymous engagement tracking rather than authenticated identity. Document this behavior and consider product rules for how long guest like records should be retained.
- Is there built-in rate limiting or bot protection for guest likes?
- The package focuses on the like relationship itself and does not replace application-level abuse protection. Add Laravel rate limiting, middleware, or bot detection around the routes that accept guest likes. Because anonymous traffic is easier to abuse than authenticated traffic, plan throttling and monitoring before exposing the feature publicly.
- How do I upgrade from version 1.4.x to 1.5.0 safely?
- Confirm that your application runs Laravel 12 or 13, then update the package with Composer and run any new migrations. Test authenticated and guest like flows in staging, including duplicate prevention and model deletion behavior, before deploying to production. Keep the previous composer lockfile and a database backup available for rollback.
- What are alternatives to this package for likes and reactions in Laravel?
- You can build a custom polymorphic likes table with your own trait if you need tight control over guest identity, moderation, or analytics. Other community packages may offer broader reaction systems, but they often add more configuration and dependencies. This package is best for lightweight like, unlike, and hasLiked behavior on Eloquent models without a full social graph.