2017 © Pedro Peláez
 

php laravel-dislikeable

Trait for Laravel Eloquent models to allow easy implementation of a 'dislike' feature.

image

shubhang/laravel-dislikeable

Trait for Laravel Eloquent models to allow easy implementation of a 'dislike' feature.

  • Thursday, March 1, 2018
  • by shubhang
  • Repository
  • 2 Watchers
  • 2 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Laravel DisLikeable Plugin

Trait for Laravel Eloquent models to allow easy implementation of a "Dislike" feature., (*1)

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

The Versions

01/03 2018

dev-master

9999999-dev

Trait for Laravel Eloquent models to allow easy implementation of a 'dislike' feature.

  Sources   Download

MIT

The Requires

 

The Development Requires

by shubhang-arora

laravel laravel 5 dislike dislikable

09/01 2017

1.0

1.0.0.0

Trait for Laravel Eloquent models to allow easy implementation of a 'dislike' feature.

  Sources   Download

MIT

The Requires

 

The Development Requires

by shubhang-arora

laravel laravel 5 dislike dislikable