Weave Code
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 Markable

Laravel Markable Laravel Package

maize-tech/laravel-markable

Add likes, bookmarks, favorites, reactions and more to Laravel models with a simple “markable” system. Includes install command, configurable user model and table prefix, and optional publishable migrations per mark type for quick setup.

View on GitHub
Deep Wiki
Context7

Laravel Markable

Frequently asked questions about Laravel Markable
How do I quickly add likes, bookmarks, or reactions to my Laravel models?
Run `composer require maize-tech/laravel-markable`, then execute `php artisan markable:install` to publish the config. Publish only the migrations you need (e.g., `markable-migration-like`) and run `php artisan migrate`. Use the `Markable` trait on your models and define the marks array to enable features instantly.
What Laravel versions does this package support?
The package officially supports Laravel 11 and 12 (as of v3.0+), with backward compatibility for older versions. Check the [GitHub releases](https://github.com/maize-tech/laravel-markable/releases) for version-specific details before upgrading.
Can I create custom mark types beyond likes, bookmarks, or reactions?
Yes, the package supports custom mark types. Extend the `Mark` class, publish a migration for your new table, and add it to the `$marks` array in your model. Each custom mark type requires its own table (e.g., `markable_custom_marks`).
How do I optimize performance for high-traffic models with many marks?
Add composite indexes on `markable_id`, `user_id`, and `value` columns in your markable tables. Use eager loading (e.g., `$model->with(['likes.user'])`) to avoid N+1 queries. For read-heavy operations, consider caching frequent queries (e.g., 'has user liked this?') with Redis.
Does this package work with Laravel’s query builder scopes like `whereHasLike()`?
Yes, the package provides dynamic scopes like `whereHasLike()`, `whereHasBookmark()`, etc. These scopes generate SQL joins under the hood. For complex queries, ensure your markable tables are properly indexed to avoid performance bottlenecks.
How do I handle metadata for marks (e.g., timestamps, context-specific data)?
Metadata is stored as JSON in a `metadata` column of the markable tables. You can access or update it via `$mark->metadata`. For validation or querying metadata, use Laravel’s JSON query methods or enforce constraints in application logic.
What’s the best way to test models using the `Markable` trait?
Mock static facade methods (e.g., `Like::add()`) in unit tests by overriding them or using partial mocks. For integration tests, verify mark persistence, relation queries, and custom value validation. Use Laravel’s testing helpers to assert relations like `$model->likes()->count()`.
Can I change the default table prefix (e.g., `markable_`) or user model?
Yes, configure the `user_model` and `table_prefix` in the published `config/markable.php` file. This allows alignment with existing database schemas or custom naming conventions without modifying the package’s core logic.
Are there alternatives to this package for Laravel markable features?
Alternatives include `spatie/laravel-activitylog` (for activity tracking), `laravel-activity` (for event-based marks), or custom solutions using Eloquent relations. However, `laravel-markable` is specialized for likes, bookmarks, and reactions with built-in scopes and metadata support.
How do I bulk-add marks (e.g., like all posts in a feed) if the package doesn’t support it natively?
The package lacks native bulk operations, but you can implement them manually using loops or Laravel’s queue system. For example, queue `Like::add()` calls for each post in a feed to avoid timeouts. Alternatively, use raw SQL or a database transaction for batch inserts.
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.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony