Enable users to watch various models in your application.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Laravel Watchable

Packagist Packagist Travis

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


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.

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

'providers' => [

Publish and run the database migrations

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

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

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

Watch a model

$book = Book::first();

Unwatch a model

$book = Book::first();

Toggle the watching of a model

$book = Book::first();

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

$book = Book::first();

Find out if the current user is watching the model

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

Get a collection of the user who are watching a model

$book = Book::first();

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));


The MIT License (MIT). Please see License File for more information.