You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A simple wishlist implementation for DRY applications
Installation
composer require reinvanoyen/oak-wishlist
Example usage
Prepare your item
<?phpuseTnt\Wishlist\Contracts\WishlistItemInterface;
classProductimplementsWishlistItemInterface
{
publicstaticfunctiongetByWishlistId(int$id): ?WishlistItemInterface
{
// get the product by id
}
publicfunctiongetWishlistId(): int
{
return1;
}
publicfunctionserialize(): array
{
return [
'id' => $this->getWishListId(),
'title' => 'Your wishlistable product #1',
];
}
}
Use of the facade
<?phpuseTnt\Wishlist\Facade\Wishlist;
$product = newProduct();
// Add an itemWishlist::add($product);
// Remove an itemWishlist::remove($product);
// Check if an item is wishlistedif (Wishlist::has($product)) {
echo'Yes, it is a wishlisted item!';
}
// Retrieve all wishlisted itemsWishlist::getItems();
// Clear all items from the wishlistWishlist::clear();