- How do I install overtrue/laravel-subscribe in a Laravel app?
- Install it with Composer using composer require overtrue/laravel-subscribe, then publish the package migration if you want to customize the subscriptions table. Laravel's package discovery registers the service provider automatically, so no manual provider entry is needed in most applications. Run php artisan migrate after publishing, and confirm your Composer platform constraints match the package's supported PHP and Laravel versions.
- Which Laravel and PHP versions does laravel-subscribe 5.0.0 support?
- Version 5.0.0 targets PHP 8.3 or newer and Laravel 13.x, so it is intended for applications already on a modern platform baseline. If your app is on PHP below 8.3 or Laravel below 13.x, stay on a compatible 4.x release instead of forcing the upgrade. Confirm the exact supported Laravel 13 minor versions in the package's composer.json before changing constraints, since Composer platform requirements will block mixed-version adoption.
- How do I add subscribe and unsubscribe behavior to an Eloquent model?
- Add the package's subscriber trait to the model that will perform subscriptions, such as your User model. The trait exposes subscribe, unsubscribe, toggle, and isSubscribed helpers, along with subscribers and subscriptions relations. Any other Eloquent model can act as the subscribable target, so posts, projects, or similar records work without schema changes.
- How do the polymorphic subscriber and subscription relations work?
- The package stores subscriber and subscribable IDs polymorphically, which lets heterogeneous model types share a single subscriptions table. That makes it possible for users, teams, or other entities to subscribe to posts or any other model. When querying, validate polymorphic IDs carefully in your own contract tests, because the published suite is small and application-specific edge cases are your responsibility.
- Do I need to publish and run the package migration?
- A publishable migration ships with the package, and version 5.0.0 does not require republishing the migration during upgrade. You should still confirm migration status in staging and diff any published config and assets to catch local customizations. If you have never published it, follow the package docs and run php artisan migrate after publishing.
- What events does laravel-subscribe fire on subscribe and unsubscribe?
- The package dispatches events around subscription changes, which lets you hook notifications, analytics, or audit logging into the lifecycle. Register listeners as you normally would in a Laravel app and test them in staging, since event dispatch behavior is one of the areas the upgrade notes call out for verification. Keep application-level contract tests for listeners rather than relying only on the package's own suite.
- How do I check whether a model is subscribed or toggle a subscription?
- Use the isSubscribed helper to check the current state and the toggle helper to flip it in one call. The subscribe and unsubscribe methods handle the explicit cases, and the subscriptions and subscribers relations let you eager-load subscription data for API responses. The package also supports attaching subscription status across models, collections, and pagination results, which is useful for API-driven views.
- Can I use laravel-subscribe for follow, like, or bookmark features instead of just users?
- Yes. Because subscriptions are polymorphic, you can use the traits on any Eloquent model and treat the feature as a generic follow, bookmark, or interest system. Users can subscribe to posts or any other model, and other entity types can act as subscribers if their models use the trait. Keep naming consistent in your domain layer so the generic subscriptions table stays understandable.
- How should I test subscription behavior in my application?
- Write application-level tests for subscription lifecycle flows, event listeners, polymorphic subscriber IDs, and status attachment across models, collections, and pagination inputs. The package's own suite covers roughly 20 tests and 106 assertions with PHP 8.3, 8.4, and 8.5 plus dependency audits, which is solid hygiene but not a substitute for your contract tests. Run these checks on a staging branch before canarying a single service and then rolling out by tier.
- What is the upgrade path from laravel-subscribe 4.x to 5.0.0, and is 4.x still maintained?
- Upgrade PHP to 8.3 or newer first, then Laravel to 13.x, then the package, or adopt the package last as part of the Laravel 13 rollout. Review UPGRADING.md before branching; no migration republishing is required, but diff published config and confirm migration status in staging. Pin services that cannot yet meet the platform baseline to 4.x, and clarify the 4.x support and security-maintenance window with the maintainer before broad adoption.