PHPackages                             animelhd/animes-watching - 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. animelhd/animes-watching

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

animelhd/animes-watching
========================

User watching features for Laravel Application.

071PHP

Since May 10Pushed 1y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Watching
----------------

[](#laravel-watching)

❤️ User watching feature for Laravel Application.

[![CI](https://github.com/overtrue/laravel-watching/workflows/CI/badge.svg)](https://github.com/overtrue/laravel-watching/actions)[![Latest Stable Version](https://camo.githubusercontent.com/2b7c7a01060e9907bb6d0a3499e99af9aa1b71b1bd108c1515e9217bf9f4f748/68747470733a2f2f706f7365722e707567782e6f72672f6f766572747275652f6c61726176656c2d7761746368696e672f762f737461626c652e737667)](https://packagist.org/packages/overtrue/laravel-watching)[![Latest Unstable Version](https://camo.githubusercontent.com/02b370ed480f51b811a6c892876638fa4140016bd0e73902c884c4fbfbec4de0/68747470733a2f2f706f7365722e707567782e6f72672f6f766572747275652f6c61726176656c2d7761746368696e672f762f756e737461626c652e737667)](https://packagist.org/packages/overtrue/laravel-watching)[![Total Downloads](https://camo.githubusercontent.com/4bc37d1fc2345d6f048ebbd03c8bf23c79eaeff4ddd0becf6e2c7e2623d9cf9b/68747470733a2f2f706f7365722e707567782e6f72672f6f766572747275652f6c61726176656c2d7761746368696e672f646f776e6c6f616473)](https://packagist.org/packages/overtrue/laravel-watching)[![License](https://camo.githubusercontent.com/121b5959fcb5cd5d9ce26f11cf44627154ed3cef90956c7d5c0668ff8442d4a9/68747470733a2f2f706f7365722e707567782e6f72672f6f766572747275652f6c61726176656c2d7761746368696e672f6c6963656e7365)](https://packagist.org/packages/overtrue/laravel-watching)

[![Sponsor me](https://github.com/overtrue/overtrue/raw/master/sponsor-me-button-s.svg?raw=true)](https://github.com/sponsors/overtrue)

Installing
----------

[](#installing)

```
composer require animelhd/animes-watching -vvv
```

### Configuration &amp; Migrations

[](#configuration--migrations)

```
php artisan vendor:publish --provider="Animelhd\AnimesWatching\WatchingServiceProvider"
```

Usage
-----

[](#usage)

### Traits

[](#traits)

#### `Animelhd\AnimesWatching\Traits\Watchinger`

[](#animelhdanimeswatchingtraitswatchinger)

```
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Animelhd\AnimesWatching\Traits\Watchinger;

class User extends Authenticatable
{
    use Watchinger;

}
```

#### `Animelhd\AnimesWatching\Traits\Watchingable`

[](#animelhdanimeswatchingtraitswatchingable)

```
use Illuminate\Database\Eloquent\Model;
use Animelhd\AnimesWatching\Traits\Watchingable;

class Post extends Model
{
    use Watchingable;

}
```

### API

[](#api)

```
$user = User::find(1);
$post = Post::find(2);

$user->watching($post);
$user->unwatching($post);
$user->toggleWatching($post);
$user->getWatchingItems(Post::class)

$user->hasWatchinged($post);
$post->hasBeenWatchingedBy($user);
```

#### Get object watchingers:

[](#get-object-watchingers)

```
foreach($post->watchingers as $user) {
    // echo $user->name;
}
```

#### Get Watching Model from User.

[](#get-watching-model-from-user)

Used Watchinger Trait Model can easy to get Watchingable Models to do what you want. \_note: this method will return a `Illuminate\Database\Eloquent\Builder` \_

```
$user->getWatchingItems(Post::class);

// Do more
$watchingPosts = $user->getWatchingItems(Post::class)->get();
$watchingPosts = $user->getWatchingItems(Post::class)->paginate();
$watchingPosts = $user->getWatchingItems(Post::class)->where('title', 'Laravel-Watching')->get();
```

### Aggregations

[](#aggregations)

```
// all
$user->watchings()->count();

// with type
$user->watchings()->withType(Post::class)->count();

// watchingers count
$post->watchingers()->count();
```

List with `*_count` attribute:

```
$users = User::withCount('watchings')->get();

foreach($users as $user) {
    echo $user->watchings_count;
}

// for Watchingable models:
$posts = Post::withCount('watchingers')->get();

foreach($posts as $post) {
    echo $post->watchings_count;
}
```

### Attach user watching status to watchingable collection

[](#attach-user-watching-status-to-watchingable-collection)

You can use `Watchinger::attachWatchingStatus($watchingables)` to attach the user watching status, it will set `has_watchinged` attribute to each model of `$watchingables`:

#### For model

[](#for-model)

```
$post = Post::find(1);

$post = $user->attachWatchingStatus($post);

// result
[
    "id" => 1
    "title" => "Add socialite login support."
    "created_at" => "2021-05-20T03:26:16.000000Z"
    "updated_at" => "2021-05-20T03:26:16.000000Z"
    "has_watchinged" => true
 ],
```

#### For `Collection | Paginator | CursorPaginator | array`:

[](#for-collection--paginator--cursorpaginator--array)

```
$posts = Post::oldest('id')->get();

$posts = $user->attachWatchingStatus($posts);

$posts = $posts->toArray();

// result
[
  [
    "id" => 1
    "title" => "Post title1"
    "created_at" => "2021-05-20T03:26:16.000000Z"
    "updated_at" => "2021-05-20T03:26:16.000000Z"
    "has_watchinged" => true
  ],
  [
    "id" => 2
    "title" => "Post title2"
    "created_at" => "2021-05-20T03:26:16.000000Z"
    "updated_at" => "2021-05-20T03:26:16.000000Z"
    "has_watchinged" => false
  ],
  [
    "id" => 3
    "title" => "Post title3"
    "created_at" => "2021-05-20T03:26:16.000000Z"
    "updated_at" => "2021-05-20T03:26:16.000000Z"
    "has_watchinged" => true
  ],
]
```

#### For pagination

[](#for-pagination)

```
$posts = Post::paginate(20);

$user->attachWatchingStatus($posts);
```

### N+1 issue

[](#n1-issue)

To avoid the N+1 issue, you can use eager loading to reduce this operation to just 2 queries. When querying, you may specify which relationships should be eager loaded using the `with` method:

```
// Watchinger
$users = User::with('watchings')->get();

foreach($users as $user) {
    $user->hasWatchinged($post);
}

// with watchingable object
$users = User::with('watchings.watchingable')->get();

foreach($users as $user) {
    $user->hasWatchinged($post);
}

// Watchingable
$posts = Post::with('watchings')->get();
// or
$posts = Post::with('watchingers')->get();

foreach($posts as $post) {
    $post->isWatchingedBy($user);
}
```

### Events

[](#events)

**Event****Description**`Animelhd\AnimesWatching\Events\Watchinged`Triggered when the relationship is created.`Animelhd\AnimesWatching\Events\Unwatchinged`Triggered when the relationship is deleted.License
-------

[](#license)

MIT

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 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.

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/animelhd-animes-watching/health.svg)

```
[![Health](https://phpackages.com/badges/animelhd-animes-watching/health.svg)](https://phpackages.com/packages/animelhd-animes-watching)
```

###  Alternatives

[byjg/singleton-pattern

A lightweight PHP implementation of the Design Pattern Singleton using trait.

1055.4k2](/packages/byjg-singleton-pattern)[corneltek/assetkit

High performance asset manager.

531.4k3](/packages/corneltek-assetkit)[kriss/webman-eloquent-ide-helper

webman-eloquent-ide-helper plugin

142.7k](/packages/kriss-webman-eloquent-ide-helper)

PHPackages © 2026

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