maize-tech/laravel-markable
Add likes, bookmarks, favorites, reactions, and other “marks” to any Eloquent model. Provides traits, relationships, counters, scopes, and ready-to-publish migrations/config so you can implement markable features quickly in Laravel apps.
composer require maize-tech/laravel-markable.php artisan vendor:publish --tag="markable-migration-{type}", then php artisan migrate.php artisan vendor:publish --tag="markable-config" to customize table prefixes, user model, and allowed values.Markable trait to your model (e.g., Post, Course) and declare $marks = [Like::class]. Start adding likes with Like::add($post, $user).$marks and use static methods: add(), remove(), toggle(), has(), count().markable_ prefix (e.g., markable_bookmarks), then define a Mark-extending class (e.g., Bookmark extends Mark) and include it in $marks.allowed_values['reaction'] = ['heart', 'laugh'] in config/markable.php, then call Reaction::add($post, $user, 'heart').$post->likes (relation returns collection of Like models).$post->likers (returns User collection with mark data as pivot).Post::whereHasLike($user)->get() or whereHasReaction($user, 'heart').add()/toggle() for extra context (e.g., ['topic' => 'php']).table_prefix (markable_ by default) + mark name (e.g., markable_likes). Mismatched names cause relationship failures.allowed_values is empty or missing for a mark type, value remains NULL (e.g., likes don’t use values). When defining custom marks, remember to set allowed_values for value-based semantics.'reaction' => '*' to allow arbitrary values at runtime—useful for emoji reactions or dynamic user inputs.whereHasReaction() are fast—but avoid overusing many mark types if you’re constrained on migrations.implicit_nullable deprecations: Use PHP 8.4+ only with v2.3.1+ (this version fixes the issue).Markable trait is loaded before any custom scope overriding (whereHasLike, etc.). If needed, call parent::boot() in your model’s boot() method.How can I help you explore Laravel packages today?