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 Like Laravel Package

cslant/laravel-like

A Laravel package that adds like and favorite behavior to Eloquent models. Use traits and polymorphic relationships to like, unlike, toggle, count, and query liked items with minimal setup and clean syntax.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. csslant/laravel-like is a conventional Laravel package: a service layer (LikeManager), facade entry points (Like, Love), and Eloquent model traits (HasLike, HasLove) that proxy to the manager. This is the idiomatic Laravel shape for a cross-cutting concern — consumers get both a testable injection point (LikeManager via the container) and ergonomic static/model-level call sites. The v2.1.0 additions fill a real gap: v2.0.0 exposed model traits only, so application code that needed to react to arbitrary subjects (e.g., a controller toggling a like on a comment, a post, or a user) had no clean entry point. The facade/manager pair now covers that case without requiring consumers to instantiate interactable models first. Interaction semantics are expressed as distinct verbs (like, dislike, love, unlike, unlove, unDislike, toggle) rather than a generic type argument, which is readable but bakes a fixed taxonomy into the API surface.

Integration feasibility. Low friction: composer require, publish config and migrations, add the relevant trait(s) to each interactable model. Laravel package auto-discovery should register the service provider and facades. The main work is schema review — the release notes do not describe the storage model, so the interaction table's shape (polymorphic interactable_type/interactable_id plus user reference plus a type discriminator) must be confirmed from the migration before sizing indexes and constraints.

Technical risk.

  • Trait rename (LoveScope → LoveScopes) is a hard BC break for any v2.0.x consumer that referenced the trait by name in a model's use list or in a use statement inside application code. This is fatal at class-load time, not a soft deprecation. Mitigated only by the fact that it landed on a minor bump, which implies the maintainer considers direct trait references non-public API — worth validating against actual usage.
  • Config fallback fix changes behavior: previously, an unset like.interaction_model or like.users.model produced an error; now it silently resolves to a default. That is the right DX call but converts a loud misconfiguration into a quiet one — if the default models differ from what the adopter intended, likes may write to an unexpected table.
  • Two write paths (facade/manager vs. model traits) create a consistency question: whether both funnel through the same persistence code, or whether one bypasses manager-level concerns such as duplicate prevention, events, or counter updates. The ForgetsInteractions extraction suggests shared teardown logic, which is a good sign but does not by itself prove write-path parity.
  • Unverified concurrency semantics around toggle — a read-then-write is race-prone without a unique constraint or upsert.

Key questions.

  1. What is the supported PHP/Laravel version matrix, and does v2.1.0 require a Laravel major the platform is not yet on?
  2. Is there a unique index on (user, interactable, type)? Is toggle implemented as an atomic upsert or a read-then-write?
  3. Are interaction counts cached/denormalized on the interactable model, or always computed by aggregate query?
  4. Does LikeManager fire domain events (ModelLiked, etc.) that the application can hook for notifications and feeds?
  5. Are query scopes provided for eager-loading interaction state and counts to avoid N+1 on index pages?
  6. How are orphans handled when an interactable model is deleted — FK cascade, polymorphic cleanup, or nothing?
  7. Does the package respect the configured auth guard and multi-tenant boundaries, or does it assume a single global user model?
  8. Is the LoveScope → LoveScopes rename the only BC-affecting change in the diff?

Integration Approach

Stack fit. Well-suited to any Laravel application with Eloquent models that need lightweight reaction primitives — community/forum posts, comments, articles, internal recognition feeds. It is a poor fit if the product needs weighted reactions, reaction history/audit, or reactions on non-Eloquent entities; those would need a bespoke table and the package would become an awkward wrapper.

Migration path.

  • Greenfield (no prior package): treat v2.1.0 as the baseline. Publish config and migrations first, review the generated schema, then adopt.
  • From v2.0.0: this is nominally a minor bump, but two items require a grep before upgrading — every occurrence of LoveScope in model use lists and imports, and every place that depended on a hard failure when interaction_model or users.model was unset. Both are mechanical to fix once identified.
  • From v1.x: assume a full major migration; do not attempt a direct jump without reading the v2.0.0 upgrade notes.

Compatibility checks. Confirm the package's composer.json constraints against the platform's PHP and laravel/framework versions; verify no facade alias collision with existing Like or Love aliases in config/app.php; confirm the interaction model and user model config keys point at the intended application classes after the fallback change.

Sequencing.

  1. Spike on a branch: install, publish config and migrations, inspect the schema and generated indexes.
  2. Run migrations against a staging database seeded with realistic interaction volume; measure aggregate-count query cost on the largest interactable table.
  3. Attach HasLike to a single low-risk model and wire one user-facing surface (e.g., post likes) behind a feature flag.
  4. Add HasLove and the Love facade only after the first surface is stable, since the love/dislike taxonomy usually needs product sign-off before it ships.
  5. Backfill or dual-write only if replacing an existing reaction implementation; keep the old path readable until parity is confirmed.
  6. Roll out per-surface, not big-bang.

Operational Impact

Maintenance. Strong positive signal: v2.1.0 ships a testbench + Pest suite covering manager, facades, traits, enum, helper, and config. For a small community package, that is the difference between "safe to depend on" and "adopt at your own risk" — it means the facade/manager/trait surface is now regression-tested, and future refactors (like the ForgetsInteractions extraction in this release) can be verified rather than hoped for. The internal deduplication is housekeeping that reduces future bug surface without changing behavior.

Support. The maintainer is a single author (csslant), so bus factor is the dominant supply-side risk. Mitigate by pinning to a known-good minor and reviewing changelogs before upgrading rather than floating on ^2.1. Because the package is small, forking is a realistic fallback — worth noting in the risk register as the exit strategy.

Scaling. Interaction tables grow with engagement, not with content, so they typically become one of the largest tables in the app. Three things determine whether this scales: an index covering (interactable_type, interactable_id, type) for count lookups, an index or unique constraint covering (user, interactable, type) for "did this user react" lookups, and whether counts are computed per-request or denormalized. If the package always aggregates, high-traffic index pages will need application-level caching layered on top. Write volume from toggle is bounded by human interaction rates and is unlikely to be the bottleneck; read amplification on listing pages is the real cost.

Failure modes.

  • Fatal Class not found on upgrade for consumers referencing LoveScope directly — surfaces immediately, easy to diagnose, easy to fix.
  • Silent misconfiguration after the fallback change — likes write to the default model instead of the intended one; surfaces as wrong-looking data, harder to detect, so add an assertion or config test.
  • Duplicate interaction rows under concurrent toggle if no unique constraint exists — surfaces as inflated counts.
  • Orphaned interaction rows after interactable deletion — surfaces as drift between aggregate counts and reality; needs a cleanup job if FKs are absent.
  • N+1 queries on list views if scopes for eager-loading state are not used — surfaces as latency regression under load.

Ramp-up. Low for anyone fluent in Laravel: config file plus traits plus a facade is a familiar pattern, and the verb-per-method API reads clearly. Expect roughly half a day for a mid-level engineer to install, review the schema, attach traits to one model, and ship a working like button with tests; one to two days if replacing an existing reaction system with backfill and parity checks. The main conceptual overhead is understanding the distinction between manager/facade calls and model-trait calls well enough to pick one consistently — recommend the team standardize on the facade/manager for application code and reserve traits for model-local helpers, and document that convention up front.

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.
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle