reinvanoyen / oak-wishlist
Wishlist for Oak
Installs: 16
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 2
Open Issues: 1
pkg:composer/reinvanoyen/oak-wishlist
Requires
- reinvanoyen/dry-internal-api: ^1.0.0
- reinvanoyen/oak: ^1.0.0
This package is auto-updated.
Last update: 2025-09-20 02:05:47 UTC
README
A simple wishlist implementation for DRY applications
Installation
composer require reinvanoyen/oak-wishlist
Example usage
Prepare your item
<?php use Tnt\Wishlist\Contracts\WishlistItemInterface; class Product implements WishlistItemInterface { public static function getByWishlistId(int $id): ?WishlistItemInterface { // get the product by id } public function getWishlistId(): int { return 1; } public function serialize(): array { return [ 'id' => $this->getWishListId(), 'title' => 'Your wishlistable product #1', ]; } }
Use of the facade
<?php use Tnt\Wishlist\Facade\Wishlist; $product = new Product(); // Add an item Wishlist::add($product); // Remove an item Wishlist::remove($product); // Check if an item is wishlisted if (Wishlist::has($product)) { echo 'Yes, it is a wishlisted item!'; } // Retrieve all wishlisted items Wishlist::getItems(); // Clear all items from the wishlist Wishlist::clear();