Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Likeable Laravel Package

cybercog/laravel-likeable

Add like and dislike functionality to Laravel Eloquent models via a polymorphic many-to-many relationship. Includes reusable traits, query scopes, and events, letting users quickly like or dislike posts, comments, and any other model.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. cybercog/laravel-likeable is a trait-based, polymorphic many-to-many implementation (a Likeable trait plus a morph pivot table) that maps cleanly onto standard Eloquent conventions. It introduces no new infrastructure — only a migration and a trait — so it slots into an existing Laravel domain model without architectural negotiation. Release 3.1.0 does not change the public API or schema; it changes the resolution strategy inside the "is this model liked by this user" check to consult eager-loaded relations before issuing a query.

Integration feasibility. Low effort. composer require, publish/run the migration, add the trait to target models, and the like/unlike/check surface is available immediately. 3.1.0 is a drop-in from 3.0.1 — no migration, config, or namespace changes.

Technical risk. Low but non-zero, and concentrated entirely in the 3.1.0 behavioral change. Preferring eager-loaded relations means correctness now depends on relation freshness: if a collection was loaded before a like/unlike mutation in the same request lifecycle, the check may return a stale answer. The fallback path (query when the relation is not loaded) preserves prior behavior, so risk is scoped to endpoints that already eager-load likes. Upside is real: this is the difference between N queries and 1 for feed/listing endpoints that render liked-state per row.

Key questions.

  • Which Laravel and PHP versions does the 3.x line constrain to, and does that match our target apps?
  • Does the eager-load path correctly handle guests / null users, and does it fall back cleanly when the relation is loaded but filtered?
  • Is there test coverage for the loaded-vs-unloaded branch, and is the branch documented?
  • Does the pivot table ship with a unique constraint on (user_id, likeable_type, likeable_id), or is duplicate-like prevention our responsibility?
  • What is the package's release cadence and maintainer activity over the last 12 months?
  • Does like() / toggle() return semantics or event dispatching change under the new path?

Integration Approach

Stack fit. Standard Laravel (Eloquent, migrations, service container) with MySQL/Postgres/SQLite. No queue, cache, or external service dependency. Composes with API Resources, policies, and query scopes without adaptation.

Migration path. From 3.0.1: composer update cybercog/laravel-likeable and run the existing suite — nothing else. From 2.x: treat as a separate, reviewed change (2.x→3.x carries the package's own upgrade notes); do not bundle it with the 3.1.0 bump.

Compatibility. Semver-minor, no breaking changes, no deprecations. Pin to ^3.1 so the eager-load optimization is guaranteed present. Verify the framework constraint in composer.json against each consuming app before rollout.

Sequencing.

  1. Spike in a dev branch; run existing like-related tests to confirm 3.0.1 parity.
  2. Add explicit test coverage for the eager-loaded branch, including load → mutate → check ordering.
  3. Add the unique index on the pivot if absent (do this before production, not after).
  4. Adopt with('likes') (or an equivalent scoped eager load) in the listing/feed endpoints that read liked-state — this is where 3.1.0 actually pays off.
  5. Staging, then production. Document the "don't trust a stale loaded relation" convention for the team.

Operational Impact

Maintenance. Small surface area (one trait, one table, a handful of methods), so ongoing maintenance is near-zero. The dominant risk is upstream stewardship, not code complexity — confirm release cadence; if activity is thin, budget for a vendored fork.

Support. Community GitHub issues only; no vendor SLA. Internal ownership should be assigned to whoever owns the Laravel platform layer. Keep the version pin explicit so an unexpected upstream release cannot change query behavior silently.

Scaling. This release is a net scaling win: liked-state checks across collections drop from O(n) queries to a constant number when relations are eager-loaded. The pivot table remains the long-term scaling concern — ensure a composite index on (likeable_type, likeable_id, user_id) and a uniqueness constraint to prevent duplicate rows under concurrent requests.

Failure modes.

  • Stale eager-loaded relation → UI shows an incorrect liked-state after a mutation in the same request.
  • Missing unique index → duplicate like rows and inflated counts.
  • Polymorphic orphans: no FK cascade on morph columns, so deleting a likeable leaves rows behind unless cleaned up.
  • Morph-map changes altering stored likeable_type strings, silently orphaning existing likes.
  • Concurrent like/unlike races producing counter drift if counts are denormalized by the app.

Ramp-up. Roughly a day for a mid-level Laravel developer to integrate and test; half a day more to retrofit eager loading into existing read paths and codify the freshness convention. No specialized knowledge required.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums
rlacerda83/query-parser
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings