New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

shubhang/laravel-dislikeable

Trait for Laravel Eloquent models to allow easy implementation of a 'dislike' feature.
7 2
Install
composer require shubhang/laravel-dislikeable
Latest Version:1.0
PHP:>=5.3.0
Laravel:5
License:MIT
Last Updated:Mar 1, 2018
Links: GitHub  ·  Packagist
Maintainer: shubhang

Laravel DisLikeable Plugin

Trait for Laravel Eloquent models to allow easy implementation of a "Dislike" feature.

Composer Install (for Laravel 5)
composer require shubhang-arora/laravel-dislikeable "~1.0"
Install and then run the migrations
'providers' => array(
	 Shubhang\DisLikeable\DisLikeableServiceProvider::class,
);
php artisan vendor:publish --provider="Shubhang\DisLikeable\DisLikeableServiceProvider"
php artisan migrate
Setup your models
class Article extends \Illuminate\Database\Eloquent\Model {
	use Shubhang\DisLikeable\DisLikeableTrait;
}
Sample Usage
$article->dislike(); // dislike the article for current user
$article->dislike($myUserId); // pass in your own user id
$article->dislike(0); // just add dislikes to the count, and don't track by user

$article->undislike(); // remove dislike from the article
$article->undislike($myUserId); // pass in your own user id
$article->undislike(0); // remove dislikes from the count -- does not check for user

$article->dislikeCount; // get count of dislikes

$article->dislikes; // Iterable Illuminate\Database\Eloquent\Collection of existing dislikes

$article->disliked(); // check if currently logged in user disliked the article
$article->disliked($myUserId);

Article::whereDisLiked($myUserId) // find only articles where user disliked them
	->with('dislikeCounter') // highly suggested to allow eager load
	->get();
Credits
  • Shubhang Arora

Related Packages

fivesqrd/fluent-laravel

A Laravel 5 service provider for including the Fluent PHP library.

3,160 0
datastat/megapos

EON MegaPOS for laravel 5

32 0
babanesma/laravel5-routing

Laravel5 routing package

14 0

Version History

Version Released PHP Laravel License
1.0 >=5.3.0 ~5.0 MIT