modularavel/favoritable
A Laravel package that adds polymorphic favoriting to Eloquent models. Attach the trait to let users favorite and unfavorite records, then query favorites through a simple, reusable API for common app features.
CHANGELOG/commit comparison before adopting.composer require modularavel/favoritable, publish any config/migrations exposed by the service provider, then run php artisan migrate.User) and the favoritable trait to models that can be favorited. Confirm exact trait names from the README.$user->favorite($post), $user->hasFavorited($post), and $post->favorites()->count(). If the API differs, wrap it in a small app service so controllers do not depend directly on package method names.withCount or cached counters for “popular” listings to avoid N+1 queries.is_favorited on list endpoints by preloading the authenticated user’s favorite IDs rather than calling hasFavorited per item.RefreshDatabase; cover duplicate favorites, unfavoriting something not favorited, and authorization boundaries.^1.0, read the changelog, and verify the README against the installed tag before upgrading later.firstOrCreate or catch constraint violations; do not rely on UI state alone.Relation::enforceMorphMap before production data exists.user_id, favoritable_type, favoritable_id) and indexes. Missing indexes will hurt count and “has favorited” queries.How can I help you explore Laravel packages today?