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.
like, bookmark, reaction), aligning well with Laravel’s Eloquent conventions. This reduces coupling and allows for granular scaling.Markable trait enables seamless integration into existing models without requiring inheritance, preserving flexibility in model design.BackedEnum (introduced in v3.0) enhances type safety, reducing runtime errors and improving IDE support.user_model, table_prefix, allowed_values) allows for easy customization without modifying core logic.markable_likes, markable_reactions), which simplifies queries but requires careful migration planning to avoid schema conflicts.Maize\Markable\Mark).markableRelationName, markRelationName).count, has), but may increase write overhead for high-frequency actions.bookmark, like, etc.) requires discipline to avoid partial deployments. The package lacks a built-in composite migration tool.BackedEnum integration is elegant, it introduces a dependency on PHP 8.1+ and may require additional validation logic in older environments.like, bookmark, reaction) will be used? More types increase migration complexity.Reaction::count() be called frequently on high-traffic models?BackedEnum be used for mark values? If yes, is PHP 8.1+ a hard requirement?value column to markable_reactions)?auth()->user() for mark ownership.assertDatabaseHas for mark assertions).Reaction::count() cached per model).Post, Course).like, bookmark) and whether custom marks are needed.composer require maize-tech/laravel-markable.php artisan markable:install.user_model and table_prefix in config/markable.php.bookmark, like, etc.) and run php artisan migrate in one deployment. Risk: Downtime if migrations fail.like). Risk: Inconsistent mark types across models.down() methods to add tables without downtime (requires careful planning).Markable trait and define $marks in target models (e.g., Post, Course).use Maize\Markable\Markable;
use Maize\Markable\Models\Like;
class Post extends Model {
use Markable;
protected static $marks = [Like::class];
}
Maize\Markable\Mark for custom marks (e.g., Bookmark).allowed_values in config for marks with restricted values (e.g., reactions).BackedEnum for type-safe mark values if using PHP 8.1+.Like::add(), Reaction::count()).assertDatabaseHas to verify mark persistence.BackedEnum support (optional feature).Like::add()) for async processing.Markable trait) in a separate step to avoid coupling./posts/{id}/like).Reaction::count()).config/markable.php) reduces drift but requires discipline to update it consistently across environments.value column) requires:
Like::toggle()) handle duplicates gracefully.user_id in mark tables matches authenticated users.count() or has() operations on large datasets.Like::add() events).How can I help you explore Laravel packages today?