PHPackages                             laravel-interaction/favorite - 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. laravel-interaction/favorite

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

laravel-interaction/favorite
============================

User favorite/unfavorite behaviour for Laravel.

3.5.0(1mo ago)271MITPHPPHP ^8.0

Since Apr 30Pushed 1mo ago1 watchersCompare

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

READMEChangelog (1)Dependencies (12)Versions (27)Used By (0)

Laravel Favorite
================

[](#laravel-favorite)

User favorite/unfavorite behaviour for Laravel.

[![Latest Stable Version](https://camo.githubusercontent.com/93652a68923b29ffab30daec177df14e86962f043ea3d3541a88b2f230d4bb05/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d696e746572616374696f6e2f6661766f726974652f762f737461626c652e737667)](https://packagist.org/packages/laravel-interaction/favorite)[![Total Downloads](https://camo.githubusercontent.com/12047ec3698de66f39e446185e730499090f5368a0824d1cd6d57bd99460d8e3/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d696e746572616374696f6e2f6661766f726974652f646f776e6c6f616473)](https://packagist.org/packages/laravel-interaction/favorite)[![Latest Unstable Version](https://camo.githubusercontent.com/0f599255d360e732ada0517189ddde7450434ba3bff29d3a34ad0dedd8d97590/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d696e746572616374696f6e2f6661766f726974652f762f756e737461626c652e737667)](https://packagist.org/packages/laravel-interaction/favorite)[![License](https://camo.githubusercontent.com/f1ce93d356c94b6504fadc119177d5f4a958c68aa6bce70dd352325c82683e27/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d696e746572616374696f6e2f6661766f726974652f6c6963656e7365)](https://packagist.org/packages/laravel-interaction/favorite)

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

[](#introduction)

It let people express how they feel about the model(documentation/subject/topic).

[![](https://camo.githubusercontent.com/d204c327ea72a68b35f96c7e0f17139ab8ff894479c5ab3e1e175bcbb3255b18/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2545322539442541342d312e326b2d677265656e3f7374796c653d736f6369616c)](https://camo.githubusercontent.com/d204c327ea72a68b35f96c7e0f17139ab8ff894479c5ab3e1e175bcbb3255b18/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2545322539442541342d312e326b2d677265656e3f7374796c653d736f6369616c)

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

[](#installation)

### Requirements

[](#requirements)

- [PHP 8.0+](https://php.net/releases/)
- [Composer](https://getcomposer.org)
- [Laravel 8.0+](https://laravel.com/docs/releases)

### Instructions

[](#instructions)

Require Laravel Favorite using [Composer](https://getcomposer.org).

```
composer require laravel-interaction/favorite
```

Publish configuration and migrations

```
php artisan vendor:publish --tag=favorite-config
php artisan vendor:publish --tag=favorite-migrations
```

Run database migrations.

```
php artisan migrate
```

Usage
-----

[](#usage)

### Setup Favoriter

[](#setup-favoriter)

```
use Illuminate\Database\Eloquent\Model;
use LaravelInteraction\Favorite\Concerns\Favoriter;

class User extends Model
{
    use Favoriter;
}
```

### Setup Favoriteable

[](#setup-favoriteable)

```
use Illuminate\Database\Eloquent\Model;
use LaravelInteraction\Favorite\Concerns\Favoriteable;

class Channel extends Model
{
    use Favoriteable;
}
```

### Favoriter

[](#favoriter)

```
use LaravelInteraction\Favorite\Tests\Models\Channel;
/** @var \LaravelInteraction\Favorite\Tests\Models\User $user */
/** @var \LaravelInteraction\Favorite\Tests\Models\Channel $channel */
// Favorite to Favoriteable
$user->favorite($channel);
$user->unfavorite($channel);
$user->toggleFavorite($channel);

// Compare Favoriteable
$user->hasFavorited($channel);
$user->hasNotFavorited($channel);

// Get favorited info
$user->favoriterFavorites()->count();

// with type
$user->favoriterFavorites()->withType(Channel::class)->count();

// get favorited channels
Channel::query()->whereFavoritedBy($user)->get();

// get favorited channels doesnt favorited
Channel::query()->whereNotFavoritedBy($user)->get();
```

### Favoriteable

[](#favoriteable)

```
use LaravelInteraction\Favorite\Tests\Models\User;
use LaravelInteraction\Favorite\Tests\Models\Channel;
/** @var \LaravelInteraction\Favorite\Tests\Models\User $user */
/** @var \LaravelInteraction\Favorite\Tests\Models\Channel $channel */
// Compare Favoriter
$channel->isFavoritedBy($user);
$channel->isNotFavoritedBy($user);
// Get favoriters info
$channel->favoriters->each(function (User $user){
    echo $user->getKey();
});

$channels = Channel::query()->withCount('favoriters')->get();
$channels->each(function (Channel $channel){
    echo $channel->favoriters()->count(); // 1100
    echo $channel->favoriters_count; // "1100"
    echo $channel->favoritersCount(); // 1100
    echo $channel->favoritersCountForHumans(); // "1.1K"
});
```

### Events

[](#events)

EventFired`LaravelInteraction\Favorite\Events\Favorited`When an object get favorited.`LaravelInteraction\Favorite\Events\Unfavorited`When an object get unfavorited.License
-------

[](#license)

Laravel Favorite is an open-sourced software licensed under the [MIT license](LICENSE).

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance89

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 93.3% 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 ~71 days

Recently: every ~274 days

Total

26

Last Release

55d ago

Major Versions

0.6.0 → 1.0.0-alpha.12021-08-28

0.6.1 → 1.0.0-alpha.22021-08-31

1.x-dev → 2.0.0-beta.12022-03-10

2.x-dev → 3.0.02022-11-27

PHP version history (3 changes)0.4.0PHP ^7.2 || ^8.0

2.0.0-beta.1PHP ^7.3 || ^8.0

3.0.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/5fafa5bffa28dcd722432b244bf3f0bfe773406df29fea295847e2397b95d50b?d=identicon)[zingimmick](/maintainers/zingimmick)

---

Top Contributors

[![zingimmick](https://avatars.githubusercontent.com/u/26657141?v=4)](https://github.com/zingimmick "zingimmick (42 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

favoritefavoriteslaravellaravelfavoriteFavorites

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/laravel-interaction-favorite/health.svg)

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

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[laravel-interaction/bookmark

User bookmark/unbookmark behaviour for Laravel.

105.0k](/packages/laravel-interaction-bookmark)[glhd/special

1929.4k](/packages/glhd-special)[bjuppa/laravel-blog

Add blog functionality to your Laravel project

483.3k2](/packages/bjuppa-laravel-blog)

PHPackages © 2026

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