PHPackages                             gorankrgovic/laravel-likeable - 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. [Database &amp; ORM](/categories/database)
4. /
5. gorankrgovic/laravel-likeable

ActiveLibrary[Database &amp; ORM](/categories/database)

gorankrgovic/laravel-likeable
=============================

Make Laravel Eloquent models Likeable using UUIDs.

v0.0.4(7y ago)264MITPHPPHP ^7.0

Since Jan 17Pushed 7y ago2 watchersCompare

[ Source](https://github.com/gorankrgovic/laravel-likeable)[ Packagist](https://packagist.org/packages/gorankrgovic/laravel-likeable)[ Docs](https://github.com/gorankrgovic/laravel-likeable)[ RSS](/packages/gorankrgovic-laravel-likeable/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (8)Versions (5)Used By (0)

Laravel Likeable
================

[](#laravel-likeable)

Introduction
------------

[](#introduction)

This package is basically a simplified fork of a [Laravel Love](https://github.com/cybercog/laravel-love) package with only using LIKE and UNLIKE capability. "Laravel Love" have more capabilities such as both "LIKE" and "DISLIKE" functionality.

Also, worth noting that this package utilizes usage of UUID's instead of integer ID's. And the "Likeable" and "Liker" models needs to utilize UUIDs as well. If you are not using UUID's please use the [cybercog/laravel-likeable](https://github.com/cybercog/laravel-likeable), [cybercog/laravel-love](https://github.com/cybercog/laravel-love) or any of the alternatives listed below.

For the UUID generation this package uses [Ramsey UUID](https://github.com/ramsey/uuid).

Features
--------

[](#features)

- Uses UUIDs instead of integers (your user model must use them as well!)
- Designed to work with Laravel Eloquent models.
- Using contracts to keep high customization capabilities.
- Using traits to get functionality out of the box.
- Most part of the the logic is handled by the `LikeableService`.
- Has Artisan command `golike:recount {model?}` to re-fetch like counters.
- Subscribes for one model are mutually exclusive.
- Get Likeable models ordered by likes count.
- Events for `like`, `unlike` methods.
- Following PHP Standard Recommendations:
    - [PSR-1 (Basic Coding Standard)](http://www.php-fig.org/psr/psr-1/).
    - [PSR-2 (Coding Style Guide)](http://www.php-fig.org/psr/psr-2/).
    - [PSR-4 (Autoloading Standard)](http://www.php-fig.org/psr/psr-4/).

Alternatives
------------

[](#alternatives)

- [cybercog/laravel-love](https://github.com/cybercog/laravel-love)
- [cybercog/laravel-likeable](https://github.com/cybercog/laravel-likeable)
- [rtconner/laravel-likeable](https://github.com/rtconner/laravel-likeable)
- [faustbrian/laravel-likeable](https://github.com/faustbrian/Laravel-Likeable)
- [sukohi/evaluation](https://github.com/SUKOHI/Evaluation)
- [zvermafia/lavoter](https://github.com/zvermafia/lavoter)
- [francescomalatesta/laravel-reactions](https://github.com/francescomalatesta/laravel-reactions)
- [muratbsts/laravel-reactable](https://github.com/muratbsts/laravel-reactable)

Installation
------------

[](#installation)

First, pull in the package through Composer.

```
$ composer require gorankrgovic/laravel-likeable
```

#### Perform Database Migration

[](#perform-database-migration)

At last you need to publish and run database migrations.

```
$ php artisan migrate
```

If you want to make changes in migrations, publish them to your application first.

```
$ php artisan vendor:publish --provider="Gox\Laravel\Likeable\Providers\LikeableServiceProvider" --tag=migrations
```

Usage
-----

[](#usage)

### Prepare Liker Model

[](#prepare-liker-model)

Use `Gox\Contracts\Likeble\Liker\Models\Liker` contract in model which will get likes behavior and implement it or just use `Gox\Laravel\Likeable\Liker\Models\Traits\Liker` trait.

```
use Gox\Contracts\Likeable\Liker\Models\Liker as LikerContract;
use Gox\Laravel\Likeable\Liker\Models\Traits\Liker;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements LikerContract
{
    use Liker;
}
```

### Prepare Likeable Model

[](#prepare-likeable-model)

Use `Gox\Contracts\Likeable\Likeable\Models\Likeable` contract in model which will get likes behavior and implement it or just use `Gox\Laravel\Likeable\Likeable\Models\Traits\Likeable` trait.

```
use Gox\Contracts\Likeable\Likeable\Models\Likeable as LikeableContract;
use Gox\Laravel\Likeable\Likeable\Models\Traits\Likeable;
use Illuminate\Database\Eloquent\Model;

class Article extends Model implements LikeableContract
{
    use Likeable;
}
```

### Available Methods

[](#available-methods)

#### Likes

[](#likes)

##### Like model

[](#like-model)

```
$user->like($article);

$article->likeBy(); // current user
$article->likeBy($user->id);
```

##### Remove like mark from model

[](#remove-like-mark-from-model)

```
$user->unlike($article);

$article->unlikeBy(); // current user
$article->unlikeBy($user->id);
```

##### Get model likes count

[](#get-model-likes-count)

```
$article->likesCount;
```

##### Get model likes counter

[](#get-model-likes-counter)

```
$article->likesCounter;
```

##### Get likes relation

[](#get-likes-relation)

```
$article->likes();
```

##### Get iterable `Illuminate\Database\Eloquent\Collection` of existing model likes

[](#get-iterable-illuminatedatabaseeloquentcollection-of-existing-model-likes)

```
$article->likes;
```

##### Boolean check if user likes model

[](#boolean-check-if-user-likes-model)

```
$user->hasLiked($article);

$article->liked; // current user
$article->isLikedBy(); // current user
$article->isLikedBy($user->id);
```

*Checks in eager loaded relations `likes` first.*

##### Get collection of users who likes model

[](#get-collection-of-users-who-likes-model)

```
$article->collectLikers();
```

##### Delete all likers for model

[](#delete-all-likers-for-model)

```
$article->removeLikes();
```

### Scopes

[](#scopes)

##### Find all articles liked by user

[](#find-all-articles-liked-by-user)

```
Article::whereLikedBy($user->id)
    ->with('likesCounter') // Allow eager load (optional)
    ->get();
```

##### Fetch Likeable models by likes count

[](#fetch-likeable-models-by-likes-count)

```
$sortedArticles = Article::orderByLikesCount()->get();
$sortedArticles = Article::orderByLikesCount('asc')->get();
```

*Uses `desc` as default order direction.*

### Events

[](#events)

On each like added `\Gox\Laravel\Subscribe\Subscribeable\Events\LikeableWasLiked` event is fired.

On each like removed `\Gox\Laravel\Subscribe\Subscribeable\Events\LikeableWasUnliked` event is fired.

### Console Commands

[](#console-commands)

##### Recount likes of all model types

[](#recount-likes-of-all-model-types)

```
$ golike:recount
```

##### Recount of concrete model type (using morph map alias)

[](#recount-of-concrete-model-type-using-morph-map-alias)

```
$ golike:recount --model="article"
```

##### Recount of concrete model type (using fully qualified class name)

[](#recount-of-concrete-model-type-using-fully-qualified-class-name)

```
$ golike:recount --model="App\Models\Article"
```

Security
--------

[](#security)

If you discover any security related issues, please email me instead of using the issue tracker.

License
-------

[](#license)

- `Laravel Likeable` package is open-sourced software licensed under the [MIT license](LICENSE) by Goran Krgovic.
- `Laravel Love` package is open-sourced software licensed under the [MIT license](LICENSE) by Anton Komarev.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity48

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

Every ~19 days

Total

4

Last Release

2612d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

laraveleloquenttraituuidlikeUnlikegorankrgovic

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/gorankrgovic-laravel-likeable/health.svg)

```
[![Health](https://phpackages.com/badges/gorankrgovic-laravel-likeable/health.svg)](https://phpackages.com/packages/gorankrgovic-laravel-likeable)
```

###  Alternatives

[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k302.7k1](/packages/cybercog-laravel-love)[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[cybercog/laravel-ban

Laravel Ban simplify blocking and banning Eloquent models.

1.1k651.8k11](/packages/cybercog-laravel-ban)[rtconner/laravel-likeable

Trait for Laravel Eloquent models to allow easy implementation of a 'like' or 'favorite' or 'remember' feature.

394388.0k5](/packages/rtconner-laravel-likeable)[qirolab/laravel-reactions

Implement reactions (like, dislike, love, emotion etc) on Laravel Eloquent models.

19564.6k](/packages/qirolab-laravel-reactions)[cybercog/laravel-ownership

Laravel Ownership simplify management of Eloquent model's owner.

9126.6k3](/packages/cybercog-laravel-ownership)

PHPackages © 2026

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