PHPackages                             modularavel/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. modularavel/likeable

ActiveLibrary

modularavel/likeable
====================

A Laravel Livewire package for adding like/dislike functionality to Eloquent models

1.0.0(7mo ago)00MITPHPPHP &gt;=8.0

Since Oct 1Pushed 7mo agoCompare

[ Source](https://github.com/modularavel/likeable)[ Packagist](https://packagist.org/packages/modularavel/likeable)[ Docs](https://github.com/modularavel)[ RSS](/packages/modularavel-likeable/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

Modularavel Likeable
====================

[](#modularavel-likeable)

A Laravel Livewire package for adding like and dislike functionality to your Eloquent models with beautiful TailwindCSS styled components.

Features
--------

[](#features)

- Like and dislike any Eloquent model
- Real-time updates with Livewire
- Support for authenticated users and guest tracking via IP
- Beautiful TailwindCSS styled button component
- Dark mode support
- Configurable options
- Easy to integrate and use

Requirements
------------

[](#requirements)

- PHP 8.0 or higher
- Laravel 9.x, 10.x, or 11.x
- Livewire 2.x or 3.x
- TailwindCSS

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

[](#installation)

### 1. Install the package via Composer

[](#1-install-the-package-via-composer)

```
composer require modularavel/likeable
```

### 2. Publish the migrations

[](#2-publish-the-migrations)

```
php artisan vendor:publish --tag=likeable-migrations
```

### 3. Run migrations

[](#3-run-migrations)

```
php artisan migrate
```

### 4. (Optional) Publish the configuration file

[](#4-optional-publish-the-configuration-file)

```
php artisan vendor:publish --provider="Modularavel\Likeable\LikeableServiceProvider" --tag=config
```

### 5. (Optional) Publish the views for customization

[](#5-optional-publish-the-views-for-customization)

```
php artisan vendor:publish --tag=likeable-views
```

Usage
-----

[](#usage)

### 1. Add the Likeable trait to your model

[](#1-add-the-likeable-trait-to-your-model)

```
use Modularavel\Likeable\Traits\Likeable;

class Post extends Model
{
    use Likeable;

    // Your model code...
}
```

### 2. Use the Livewire component in your Blade views

[](#2-use-the-livewire-component-in-your-blade-views)

```

```

Or with custom options:

```

```

You can also pass the model ID and type separately:

```

```

### 3. Available Methods

[](#3-available-methods)

The `Likeable` trait provides these methods:

```
// Like/Dislike actions
$post->like();
$post->dislike();

// Get counts
$post->likesCount();
$post->dislikesCount();

// Check if liked/disliked by current user or IP
$post->isLikedBy();
$post->isDislikedBy();

// Relationships
$post->likes;
$post->dislikes;
$post->allLikes;
```

### 4. Using programmatically

[](#4-using-programmatically)

```
// Like a post
$post->like(); // Uses current authenticated user or IP

// Dislike a post
$post->dislike();

// Like/Dislike with specific user
$post->like($userId);
$post->dislike($userId);

// Get like count
$likesCount = $post->likesCount();
$dislikesCount = $post->dislikesCount();

// Check if user has liked
if ($post->isLikedBy()) {
    // User has liked this post
}

// Check if user has disliked
if ($post->isDislikedBy()) {
    // User has disliked this post
}
```

Configuration
-------------

[](#configuration)

The configuration file allows you to customize the package behavior:

```
return [
    // User model to use
    'user_model' => App\Models\User::class,

    // Track guests by IP address
    'track_by_ip' => true,

    // Show counts on buttons
    'show_counts' => true,

    // Enable/disable dislikes
    'enable_dislikes' => true,
];
```

Customization
-------------

[](#customization)

### Styling

[](#styling)

The component uses TailwindCSS classes. If you want to customize the appearance, publish the views:

```
php artisan vendor:publish --tag=likeable-views
```

Then edit the view files in `resources/views/vendor/likeable/`.

### Dark Mode

[](#dark-mode)

The component includes built-in dark mode support using TailwindCSS dark mode classes.

Component Props
---------------

[](#component-props)

PropTypeDefaultDescription`model`ModelnullThe Eloquent model instance`modelId`intnullThe model ID (alternative to passing model)`modelType`stringnullThe model class name (alternative to passing model)`showCount`booltrueShow like/dislike counts`showDislike`booltrueShow dislike buttonEvents
------

[](#events)

The component emits these Livewire events:

- `likeToggled` - Fired when like is toggled
- `dislikeToggled` - Fired when dislike is toggled
- `refreshLikes` - Listen to this to refresh like counts

Example of listening to events:

```

    Livewire.on('likeToggled', (modelId, modelType) => {
        console.log('Like toggled for', modelType, modelId);
    });

```

Database Schema
---------------

[](#database-schema)

The package creates a `likes` table with the following structure:

- `id` - Primary key
- `likeable_type` - Polymorphic type
- `likeable_id` - Polymorphic ID
- `user_id` - User ID (nullable)
- `ip_address` - IP address (nullable)
- `type` - 'like' or 'dislike'
- `created_at` - Timestamp
- `updated_at` - Timestamp

License
-------

[](#license)

MIT License

Support
-------

[](#support)

For issues, questions, or contributions, please visit the GitHub repository.

Testing
-------

[](#testing)

```
composer test
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance62

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

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

229d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7354fd72dfef31d8a9afddab61122ab6ade014057993e0c05b1f7e0d95343742?d=identicon)[modularavel](/maintainers/modularavel)

---

Top Contributors

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

---

Tags

laravellivewirelikelikeabledislike

###  Code Quality

TestsPest

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/modularavel-likeable/health.svg)](https://phpackages.com/packages/modularavel-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)[livewire/flux

The official UI component library for Livewire.

9475.0M86](/packages/livewire-flux)[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)[mati365/ckeditor5-livewire

CKEditor 5 integration for Laravel Livewire

413.9k](/packages/mati365-ckeditor5-livewire)[jamesmills/watchable

A package to allow your Models to become watchable by a User

685.5k](/packages/jamesmills-watchable)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

116.6k](/packages/tomshaw-electricgrid)

PHPackages © 2026

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