PHPackages                             jamesmills/watchable - 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. jamesmills/watchable

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

jamesmills/watchable
====================

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

1.3.1(5y ago)685.5k14[1 PRs](https://github.com/jamesmills/watchable/pulls)MITPHPPHP ^7.0

Since Aug 31Pushed 3y ago3 watchersCompare

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

READMEChangelogDependencies (2)Versions (13)Used By (0)

Laravel Watchable
=================

[](#laravel-watchable)

[![Packagist](https://camo.githubusercontent.com/9df7597c6c9af13a7b89cd2c8cd4e87a455d399ed4b59b5c93c8ed2778a2bdc5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a616d65736d696c6c732f776174636861626c652e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/jamesmills/watchable)[![Packagist](https://camo.githubusercontent.com/3910480903c85fdecb89506421c8b8380f9f87621e4d7fac8da4e9c37495d9c3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a616d65736d696c6c732f776174636861626c652e7376673f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/3910480903c85fdecb89506421c8b8380f9f87621e4d7fac8da4e9c37495d9c3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a616d65736d696c6c732f776174636861626c652e7376673f7374796c653d666f722d7468652d6261646765)[![Travis](https://camo.githubusercontent.com/95f986cc12dd6a6a1054688b4c8cbab1f16fb46da6769c93d42116913218f7d4/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6a616d65736d696c6c732f776174636861626c652e7376673f7374796c653d666f722d7468652d6261646765)](https://travis-ci.org/jamesmills/watchable)[![Packagist](https://camo.githubusercontent.com/34d94503da978b6ed30f714d651ed50f941be48c38cad46570beb415fd5a01e4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a616d65736d696c6c732f776174636861626c652e7376673f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/34d94503da978b6ed30f714d651ed50f941be48c38cad46570beb415fd5a01e4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a616d65736d696c6c732f776174636861626c652e7376673f7374796c653d666f722d7468652d6261646765)[![Buy us a tree](https://camo.githubusercontent.com/15453546808b5ea47b48633f72f490420e2e41b885556eee95d7e88f4a754418/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f54726565776172652d2546302539462538432542332d6c69676874677265656e3f7374796c653d666f722d7468652d6261646765)](https://plant.treeware.earth/jamesmills/watchable)[![Treeware (Trees)](https://camo.githubusercontent.com/b7bf0524c1a7aa546615f63e2100b83567b14f3b2b80f36be19931367b490336/68747470733a2f2f696d672e736869656c64732e696f2f74726565776172652f74726565732f6a616d65736d696c6c732f776174636861626c653f7374796c653d666f722d7468652d6261646765)](https://plant.treeware.earth/jamesmills/watchable)

Enable users to watch various models in your application.

- Designed to work with Laravel Eloquent models
- Just add the trait to the model you would like to be watchable
- Watches are unique for one model and one user
- Events are fired on `watched` and `unwatched` methods
- Built to work with Laravel Notifications

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

[](#installation)

Pull in the package using Composer

```
composer require jamesmills/watchable

```

> **Note**: If you are using Laravel 5.5, the next step for provider are unnecessary. Laravel Watchable supports Laravel [Package Discovery](https://laravel.com/docs/5.5/packages#package-discovery).

Include the service provider within `app/config/app.php`.

```
'providers' => [
    ...
    JamesMills\Watchable\WatchableServiceProvider::class,
],
```

Publish and run the database migrations

```
php artisan vendor:publish --provider="JamesMills\Watchable\WatchableServiceProvider" --tag="migrations"
php artisan migrate
```

Sample Usage and Boilerplate
----------------------------

[](#sample-usage-and-boilerplate)

I wrote a blog post to give you some boilerplate code that you can use in your application to wrap around the Laravel Watchable package.

How to use
----------

[](#how-to-use)

### Prepare your model to be watched

[](#prepare-your-model-to-be-watched)

Simply add the `watchable` trait to your model

```
use Illuminate\Database\Eloquent\Model;
use JamesMills\Watchable\Traits\Watchable;

class Book extends Model {
    use Watchable;
}
```

### Available methods

[](#available-methods)

Watch a model

```
$book = Book::first();
$book->watch();
```

Unwatch a model

```
$book = Book::first();
$book->unwatch();
```

Toggle the watching of a model

```
$book = Book::first();
$book->toggleWatch();
```

You can optionally send the `$user_id` if you don't want to use the built in `auth()->user()->id` functionality.

```
$book = Book::first();
$book->watch($user_id);
$book->unwatch($user_id);
$book->toggleWatch($user_id);
```

Find out if the current user is watching the model

```
@if ($book->isWatched())
    {{ You are watching this book }}
@else
    {{ You are NOT watching this book }}
@endif
```

Get a collection of the user who are watching a model

```
$book = Book::first();
$book->collectWatchers();
```

### Use with Notifications

[](#use-with-notifications)

One of the main reasons I built this package was to scratch my own itch with an application I am building. I wanted to be able to send notifications to user who were watching a given model and I also wanted to allow users to be able to watch a number of different models.

```
public function pause(Order $order)
{
    $this->performAction('paused', $order);
    Notification::send($order->collectWatchers(), new OrderPaused($order));
}
```

License
-------

[](#license)

This package is 100% free and open-source, under the [MIT license](LICENSE.md). Use it however you want.

This package is [Treeware](https://treeware.earth). If you use it in production, then we ask that you [**buy the world a tree**](https://plant.treeware.earth/jamesmills/watchable) to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 76.2% 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 ~115 days

Total

12

Last Release

1906d ago

### Community

Maintainers

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

---

Top Contributors

[![jamesmills](https://avatars.githubusercontent.com/u/557096?v=4)](https://github.com/jamesmills "jamesmills (32 commits)")[![MadMikeyB](https://avatars.githubusercontent.com/u/831828?v=4)](https://github.com/MadMikeyB "MadMikeyB (3 commits)")[![cmgmyr](https://avatars.githubusercontent.com/u/4693481?v=4)](https://github.com/cmgmyr "cmgmyr (2 commits)")[![anthonysterling](https://avatars.githubusercontent.com/u/159960?v=4)](https://github.com/anthonysterling "anthonysterling (2 commits)")[![furqanfreed](https://avatars.githubusercontent.com/u/2947357?v=4)](https://github.com/furqanfreed "furqanfreed (1 commits)")[![carusogabriel](https://avatars.githubusercontent.com/u/16328050?v=4)](https://github.com/carusogabriel "carusogabriel (1 commits)")[![rrrhys](https://avatars.githubusercontent.com/u/361922?v=4)](https://github.com/rrrhys "rrrhys (1 commits)")

---

Tags

eloquentlaravellaravel-5-packagepackagephp7watchablelaravelpackageeloquentPHP7likewatchlikeablelaravel-5-packagewatchable

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/jamesmills-watchable/health.svg)

```
[![Health](https://phpackages.com/badges/jamesmills-watchable/health.svg)](https://phpackages.com/packages/jamesmills-watchable)
```

###  Alternatives

[cybercog/laravel-love

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

1.2k302.7k1](/packages/cybercog-laravel-love)[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)[devdojo/laravel-reactions

3529.7k](/packages/devdojo-laravel-reactions)[onramplab/laravel-custom-fields

An laravel package that enables custom field support for any Laravel models

103.9k](/packages/onramplab-laravel-custom-fields)

PHPackages © 2026

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