batuhan/laravel-flaggable
Laravel Flaggable Plugin
Trait for Laravel Eloquent models to allow easy implementation of a "flag" feature. Only tested with Laravel 5.
Composer Install (for Laravel 5)
composer require batuhan/laravel-flagable "~1.0.0"
Install and then run the migrations
'providers' => array(
'Conner\Likeable\LikeableServiceProvider',
);
php artisan vendor:publish --provider="Conner\Likeable\LikeableServiceProvider"
php artisan migrate
Setup your models
class Article extends \Illuminate\Database\Eloquent\Model {
use Conner\Likeable\LikeableTrait;
}
Sample Usage
$article->flag(); // like the article for current user
$article->flag($myUserId); // pass in your own user id
$article->flag(0); // just add flags to the count, and don't track by user
$article->unflag(); // remove flag from the article
$article->unflag($myUserId); // pass in your own user id
$article->unflag(0); // remove flags from the count -- does not check for user
$article->flagCount; // get count of flags
$article->flags; // Iterable Illuminate\Database\Eloquent\Collection of existing flags
$article->flaged(); // check if currently logged in user flaged the article
$article->flaged($myUserId);
Article::whereflaged($myUserId) // find only articles where user flaged them
->with('flagCounter') // highly suggested to allow eager load
->get();
Credits
- Robert Conner - http://smartersoftware.net
Related Packages
thezeroday/laravel-likeable
Trait for Laravel Eloquent models to allow easy implementation of a 'like' or 'f...
1,225
0
turahe/laravel-likeable
Trait for Laravel Eloquent models to allow easy implementation of a 'like' or 'f...
1,828
9
cybercog/laravel-love
Make Laravel Eloquent models reactable with any type of emotions in a minutes!
359,084
1,203
qirolab/laravel-reactions
Implement reactions (like, dislike, love, emotion etc) on Laravel Eloquent model...
83,134
196
ufutx/laravel-favorite
Allows Laravel Eloquent models to implement a 'favorite' or 'remember' or 'follo...
167
6
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 1.0.0 | >=5.3.0 | 5.* | MIT |