PHPackages                             alpetg/wishlist - 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. alpetg/wishlist

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

alpetg/wishlist
===============

Make Models wishlistable

41PHP

Since Sep 24Pushed 3y ago1 watchersCompare

[ Source](https://github.com/AlpetGexh/lara-wish)[ Packagist](https://packagist.org/packages/alpetg/wishlist)[ RSS](/packages/alpetg-wishlist/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Wishlist
================

[](#laravel-wishlist)

Make Eloquent Model models wishlistable

Installation
============

[](#installation)

You can install the package via composer:

```
composer require alpetg/wishlist
```

### Migrations

[](#migrations)

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="wishlist-migrations"
php artisan migrate
```

### Configuration

[](#configuration)

You can publish the config file with:

```
php artisan vendor:publish --tag="wishlist-config"
```

Usage
=====

[](#usage)

### Prepare Models

[](#prepare-models)

Add `Wishlist` on User Model

```
use AlpetG\Wishlist\Traits\Wishlist;

class User extends Authenticatable
{
    use Wishlist;

}
```

Add `Wishlistable` on every model u want have wishlist on

```
use AlpetG\Wishlist\Traits\Wishlistable;

class Products extends Model
{
    use Wishlistable;

}
```

### API

[](#api)

```
$user    = User::find(1);
$product = Product::find(3);

$user->wish($product);
$user->unwish($product);
$user->toggleWishlist($product);

//Or Dircet from product

$product->wish()
$product->unwish()
$product->toggleWishlist()
```

#### Aggregations

[](#aggregations)

```
// All
$user->->wishlist()->count();
//or
$user->wishlistCount();

// with type
$user->wishlist()->withType(Product::class)->count();
```

#### List with `*_count` attribute:

[](#list-with-_count-attribute)

```
$user = User::withCount('wishlist')->get();

    foreach ($user_count as $user) {
        echo $user->wishlist_count;
    }

```

### Attach the Wishlist status to wishlistable collection

[](#attach-the-wishlist-status-to-wishlistable-collection)

You can use `Wishlist::attachWishlistStatus(Collection $wishlists)` to attach the user Wishlist status, it will set `is_wishlisted` attribute to each model of `$wishlists`:

#### For model

[](#for-model)

```
$user1 = User::find(1);

$user->attachWishlistStatus($user1);

// result
[
    "id" => 1
    "name" => "user1"
    "created_at" => "2022-09-24T23:06:47.000000Z"
    "updated_at" => "2022-09-24T23:06:47.000000Z"
    "is_wishlisted" => true
  ]
```

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

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

```
$user = auth()->user();

$products = Product::oldest('id')->get();

$products = $user->attachWishlistStatus($products);

$products = $products->toArray();

// result
[
  [
    "id" => 1
    "title" => "product 1"
    "created_at" => "2022-09-24T23:06:47.000000Z"
    "updated_at" => "2022-09-24T23:06:47.000000Z"
    "is_wishlisted" => true
  ],
  [
    "id" => 2
    "title" => "product 2"
    "created_at" => "2022-09-24T23:06:47.000000Z"
    "updated_at" => "2022-09-24T23:06:47.000000Z"
    "is_wishlisted" => true
  ],
  [
    "id" => 3
    "title" => "product 3"
    "created_at" => "2022-09-24T23:06:47.000000Z"
    "updated_at" => "2022-09-24T23:06:47.000000Z"
    "is_wishlisted" => false
  ],
]
```

#### For pagination

[](#for-pagination)

```
$products = Product::paginate(10);

$user->attachWishlistStatus($products);
```

#### Easy Way to Use

[](#easy-way-to-use)

```
$products = Product::paginate(10);

$user->getMyWish($products);
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Credits
-------

[](#credits)

- [Alpet Gexha](https://github.com/AlpetG)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity25

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/04473ee8ab3de3f3ea05f7eec8600669903c9a39a397ca031fa6eb580feedc48?d=identicon)[AlpetGexh](/maintainers/AlpetGexh)

---

Top Contributors

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

---

Tags

laravelpackagewishlist

### Embed Badge

![Health badge](/badges/alpetg-wishlist/health.svg)

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

###  Alternatives

[nystudio107/craft-disqus

Integrates the Disqus commenting system into Craft CMS websites, including Single Sign On (SSO) and custom login/logout URLs

1318.4k](/packages/nystudio107-craft-disqus)

PHPackages © 2026

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