bhavinjr/laravel-wishlist

wishlist for laravel 5.*.*
1,354 8
Install
composer require bhavinjr/laravel-wishlist
Latest Version:1.4
PHP:>=5.6.0
License:MIT
Last Updated:Nov 25, 2019
Links: GitHub  ·  Packagist
Maintainer: bhavinjr

laravel-wishlist

A simple Wishlist implementation for Laravel 5...

Latest Stable Version Total Downloads License

Installation

First, you'll need to install the package via Composer:

$ composer require bhavinjr/laravel-wishlist

If you are don't use using Laravel 5.5.* Then, update config/app.php by adding an entry for the service provider.

'providers' => [
    // ...
    Bhavinjr\Wishlist\Providers\WishlistServiceProvider::class,
];

'aliases' => [
    //...
    "Wishlist": "Bhavinjr\Wishlist\Facades\Wishlist",
];

In command line paste this command:

php artisan config:cache

In command line again, publish the default configuration file:

php artisan vendor:publish --provider="Bhavinjr\Wishlist\Providers\WishlistServiceProvider"

In command line paste this command:

php artisan migrate

Configuration

Configuration was designed to be as flexible. global configuration can be set in the config/wishlist.php file.

return [
    'product_model'         =>  'App\Models\Product',
];

after update config/wishlist.php file.

php artisan config:cache

Usage

The package gives you the following methods to use:

Adding an item to the wishlist is really simple

you need specify product_id and user_id respectively all parameter are compulsory

Wishlist::add()

Wishlist::add(15, 1);

Wishlist::remove()

To remove an item from the wishlist, specify the wishlist_id.

Wishlist::remove(2);

Wishlist::getUserWishlist()

To get users all wishlist item, specify the user_id.

Wishlist::getUserWishlist(1);

Wishlist::removeUserWishlist()

To remove users all wishlist item, specify the user_id.

Wishlist::removeUserWishlist(1);

Wishlist::removeByProduct()

To remove particular product using product_id, specify the product_id and user_id respectively.

Wishlist::removeByProduct(15, 1);

Wishlist::count()

To count users all wishlist item, specify the user_id.

Wishlist::count(1);

Wishlist::getWishlistItem()

To get particular wishlist item, specify the product_id and user_id respectively

Wishlist::getWishlistItem(15, 1);

You can also load product detail

$result  =  Wishlist::getUserWishlist(1)->load('product');

or you can also access directly

Related Packages

php-tmdb/laravel

Laravel Package for TMDB ( The Movie Database ) API. Provides easy access to the...

53,315 160
kavenegar/laravel

laravel 4 and 5 kavenegar integration

368,693 86
laravel-ja/laravel

The Laravel Framework.

5,667 17