PHPackages                             nr-type/like-dislike - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. nr-type/like-dislike

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

nr-type/like-dislike
====================

This is a package for developers who want to use like and dislike options in their applications, this is the easiest way to do that.

1.0.1(4y ago)16MITPHP

Since Feb 11Pushed 4y ago1 watchersCompare

[ Source](https://github.com/iamnurr/like-dislike-bucket)[ Packagist](https://packagist.org/packages/nr-type/like-dislike)[ RSS](/packages/nr-type-like-dislike/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Laravel Like Dislike Package
============================

[](#laravel-like-dislike-package)

[![Issues](https://camo.githubusercontent.com/5605cc290fbd45f85a7bf205b8ad0e55ef201cecaf11fd6b9bff9eaeed5e4972/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f69616d6e7572722f6c696b652d6469736c696b652d6275636b65743f636f6c6f723d637269746963616c)](https://github.com/iamnurr/like-dislike-bucket/issues)[![Stars](https://camo.githubusercontent.com/4f87ea81d6f2cfe6e07ce4cf5bbfd0eeff168117e03b08158eac8bd9dd1dd175/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f69616d6e7572722f6c696b652d6469736c696b652d6275636b65743f636f6c6f723d73756363657373)](https://github.com/iamnurr/like-dislike-bucket/stargazers) [![Forks](https://camo.githubusercontent.com/3559daf5a2cf80708dce195b8ea440b7186d46c2c4fe88479cc66c1b8766ac72/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f69616d6e7572722f6c696b652d6469736c696b652d6275636b65743f636f6c6f723d396366)](https://github.com/iamnurr/like-dislike-bucket/forks) [![Tags](https://camo.githubusercontent.com/810c0185d66dfc2de836952c08876062d72face8ada895f7513ecc347da44d4b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f69616d6e7572722f6c696b652d6469736c696b652d6275636b6574)](https://github.com/iamnurr/like-dislike-bucket/tags)[![License](https://camo.githubusercontent.com/24f7b51dad67578b330fc07b8c38bffed8ceb81d5837d197a91483c1d3f0d003/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f69616d6e7572722f6c696b652d6469736c696b652d6275636b65743f636f6c6f723d6f72616e6765)](https://github.com/iamnurr/like-dislike-bucket/blob/main/LICENSE)[![Twitter](https://camo.githubusercontent.com/d2506f0cbe58da807ff0d15a1ae98f53d4b9737f3a5205d3dc3437776bc03801/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f75726c3f75726c3d68747470732533412532462532466769746875622e636f6d25324669616d6e7572722532466c696b652d6469736c696b652d6275636b6574)](https://camo.githubusercontent.com/d2506f0cbe58da807ff0d15a1ae98f53d4b9737f3a5205d3dc3437776bc03801/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f75726c3f75726c3d68747470732533412532462532466769746875622e636f6d25324669616d6e7572722532466c696b652d6469736c696b652d6275636b6574)

About Package
-------------

[](#about-package)

This is a package for developers who want to use like and dislike options in their applications, this is the easiest way to do that.

Installing
----------

[](#installing)

This package can be installed through Composer in your application :

##### Run the command.

[](#run-the-command)

```
composer require nr-type/like-dislike
```

### Migration

[](#migration)

After that run the Migration command :

```
php artisan migrate
```

Model Use
---------

[](#model-use)

The model where you want to have like and dislike. You just need to use `NrType\LikeDislike\Traits\Likeable` and `NrType\LikeDislike\Traits\Dislikeable`. And inside the class use `Likeable` and `Dislikeable`.

```
use NrType\LikeDislike\Traits\Likeable;
use NrType\LikeDislike\Traits\Dislikeable;

class Post extends Model
{
    use Likeable, Dislikeable;
}
```

##### You can use like dislike options in multiple `Model`

[](#you-can-use-like-dislike-options-in-multiple-model)

Multiple `Model` are can be `Comment`,`Video`,`Photo`.

```
use NrType\LikeDislike\Traits\Likeable;
use NrType\LikeDislike\Traits\Dislikeable;

class Comment extends Model
{
    use Likeable, Dislikeable;
}
```

Optional
--------

[](#optional)

Suppose you just only need Like option for your application. Then you use `NrType\LikeDislike\Traits\Likeable` and `Likeable`.

```
use NrType\LikeDislike\Traits\Likeable;

class Post extends Model
{
    use Likeable;
}
```

Compatibility
-------------

[](#compatibility)

`Like` and `Dislike` can work individually and also both are compatible to work with each other, suppose someone like the post and after some time later thinks that he/she wants to dislike the post. He/she just simply click the dislike button, and it will `remove` his/her `like` on that particular post and `dislike`.

Uses in Controller
==================

[](#uses-in-controller)

Like
----

[](#like)

Use like option in the post such as like 2 lines of code.

```
public function like (Post $post)
{
    $post->like();

    return redirect()->route('posts.index');
}
```

### But

[](#but)

Suppose you want that someone's `click` like button then it will like the post and again he `click` liked button then it will unlike the post. Then here is `removeLike()`. if User alreay like that post it will remove that particular like in the same method or if you want you can create another route and method to unlike the post.

```
public function like (Post $post)
{
    if($post->removeLike()){
        return redirect()->route('posts.index');
    }

    $post->like();

    return redirect()->route('posts.index');
}
```

DisLike
-------

[](#dislike)

Use dislike in the post same as like in post. For dislike options again you have `dislike()` and `removeDislike()`

```
public function dislike (Post $post)
{
    $post->dislike();

    return redirect()->route('posts.index');
}
```

### Or

[](#or)

```
public function dislike (Post $post)
{
    if ($post->removeDislike()) {
        return redirect()->route('posts.index');
    }

    $post->dislike();

    return redirect()->route('posts.index');
}
```

Likers and Dislikers on the Post
--------------------------------

[](#likers-and-dislikers-on-the-post)

You can easily access likers and dislikers through `likers()` and `dislikers()`. default it will return with users `id`,`name` from `users` table.

```
public function likers (Post $post)
{
    return $post->likers();
}
```

### Or

[](#or-1)

```
public function dislikers (Post $post)
{
    return $post->dislikers();
}
```

#### Now here has somethings

[](#now-here-has-somethings)

`likers()` and `dislikers()` default return `id`,`name` but you maybe don't need `id`, you may only need `name` or your users database table doesn't have `name` field, it can be `first_name`,`last_name` or maybe something else or maybe you need more then those fields. Here have a solution. You just pass a `array` in side the method. It will return those fields data form users table.

```
public function likers (Post $post)
{
    $fields = ['id','first_name','last_name','age'];

    return $post->likers($fields);
}
```

### Or

[](#or-2)

```
public function dislikers (Post $post)
{
    $fields = ['id','name','age'];

    return $post->dislikers($fields);
}
```

`with()` relationship call in Controller
----------------------------------------

[](#with-relationship-call-in-controller)

You can show `likes`, `dislikes` on posts and also want to show how many likes and dislike on posts with `likeCounter`, `dislikeCounter`.

```
public function index()
{
    $relations = ['likes','likeCounter','dislikes','dislikeCounter'];

    $data['posts'] = Post::with($relations)->get();

    return view('post.index', $data);
}
```

### Or

[](#or-3)

You may have `comments` on `posts` and you need `comments` and also need `likes` on particular `comment` and how many `likes` on `comment`. Then you can use `comments.likes` and `comments.likeCounter`.

```
public function index()
{
    $relations = [
        'likes',
        'likeCounter',
        'dislikes',
        'dislikeCounter',
        'comments.likes',
        'comments.likeCounter'
    ];

    $data['posts'] = Post::with($relations)->get();

    return view('post.index', $data);
}
```

Additional options
------------------

[](#additional-options)

`hasLike()`, `hasDislike()` is for check that logged in user has like or dislike in post or comment. It return `boolean`. You can use `hasLike()` `hasDislike()` in blades file as well.

```
{{ $post->hasLike() ? 'Liked' : 'Like' }}
{{ $post->hasDislike() ? 'Disliked' : 'Dislike' }}
```

License
-------

[](#license)

Like Dislike bucket is open-sourced software licensed under the [MIT license](https://github.com/iamnurr/like-dislike-bucket/blob/main/LICENSE).

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1549d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ff276b346e1a5f591b64ab8a8ac96c410fe98371e3b00b5af668e944484efbcb?d=identicon)[iamnurr](/maintainers/iamnurr)

---

Top Contributors

[![iamnurr](https://avatars.githubusercontent.com/u/91257313?v=4)](https://github.com/iamnurr "iamnurr (12 commits)")

### Embed Badge

![Health badge](/badges/nr-type-like-dislike/health.svg)

```
[![Health](https://phpackages.com/badges/nr-type-like-dislike/health.svg)](https://phpackages.com/packages/nr-type-like-dislike)
```

###  Alternatives

[bueltge/wordpress-multisite-enhancements

Enhance Multisite for Network Admins with different topics

1113.6k](/packages/bueltge-wordpress-multisite-enhancements)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
