PHPackages                             trendsoft/laravel-bookmark - 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. trendsoft/laravel-bookmark

ActiveLibrary

trendsoft/laravel-bookmark
==========================

Laravel bookmark

v0.1.1(5y ago)91316[1 PRs](https://github.com/trendsoft/laravel-bookmark/pulls)MITPHP

Since Aug 1Pushed 5y ago1 watchersCompare

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

READMEChangelog (2)Dependencies (7)Versions (3)Used By (0)

Laravel bookmark
----------------

[](#laravel-bookmark)

User bookmark feature for Laravel Application.

[![CI](https://github.com/trendsoft/laravel-bookmark/workflows/CI/badge.svg)](https://github.com/trendsoft/laravel-bookmark/workflows/CI/badge.svg)

Installing
----------

[](#installing)

```
$ composer require trendsoft/laravel-bookmark -vvv
```

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

[](#configuration)

This step is optional

```
$ composer artisan vendor:publish --provider="Trendsoft\\LaravelBookmark\\BookmarkServiceProvider" --tag=config
```

Migrations
----------

[](#migrations)

This step is also optional, if you want to custom bookmarks table, you can publish the migration files:

```
$ composer artisan vendor:publish --provider="Trendsoft\\LaravelBookmark\\BookmarkServiceProvider" --tag=migrations
```

Usage
=====

[](#usage)

Traits
------

[](#traits)

`Trendsoft\LaravelBookmark\Traits\Bookmarker`

```
use Illuminate\Database\Eloquent\Model;
use Trendsoft\LaravelBookmark\Traits\Bookmarker;

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

`Trendsoft\LaravelBookmark\Traits\Bookmarkable`

```
use Illuminate\Database\Eloquent\Model;
use Trendsoft\LaravelBookmark\Traits\Bookmarkable;

class Post extends Model
{
    use Bookmarkable;
}
```

API
---

[](#api)

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

$user->bookmark($post);
$user->unBookmark($post);
$user->toggleBookmark($post);

$user->hasBookmarked($post);
$post->isBookmarkedBy($user);
```

Get user bookmarks with pagination:

```
$bookmarks = $user->bookmarks()->with('bookmarkable')->paginate(20);

foreach($bookmarks as $bookmark){
    $bookmark->bookmarkable; // App\Post instance
}
```

Get object bookmarkers:

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

with pagination:

```
$bookmarkers = $post->bookmarkers()->paginate(20);
foreach($bookmarkers as $user){
    echo $user->name;
}
```

Aggregations
------------

[](#aggregations)

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

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

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

List with `*_count` attribute:

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

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

N +1 issue
----------

[](#n-1-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:

```
// Bookmarker
$users = App\User::with('bookmarks')->get();

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

// Bookmarkable
$posts = App\Post::with('bookmarks')->get();
// or
$posts = App\Post::with('bookmarkers')->get();

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

Events
------

[](#events)

EventDescription`Trendsoft\LaravelBookmark\Events\Bookmarked`Triggered when the relationship is created.`Trendsoft\LaravelBookmark\Events\Unbookmarked`Triggered when the relationship is deleted.Contributing
------------

[](#contributing)

You can contribute in one of three ways:

- File bug reports using the [issue tracker](https://github.com/trendsoft/laravel-bookmark/issues).
- Answer questions or fix bugs on the [issue tracker](https://github.com/trendsoft/laravel-bookmark/issues).
- Contribute new features or update the wiki.

The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.

License
=======

[](#license)

MIT

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity46

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

Every ~0 days

Total

2

Last Release

2108d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2e3877002e2232ea95aa1565da2d9b54ce841aed725a661e30678d2e80731a8f?d=identicon)[hu19891110](/maintainers/hu19891110)

---

Top Contributors

[![2898117012](https://avatars.githubusercontent.com/u/20187449?v=4)](https://github.com/2898117012 "2898117012 (15 commits)")

---

Tags

bookmarklaravellaravel-packagelaravelbookmarktrendsoft

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/trendsoft-laravel-bookmark/health.svg)

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

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)

PHPackages © 2026

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