Wallogit.com
2017 © Pedro Peláez
Simple Session based cart for shopping websites
Simple Session based cart for shopping websites in Laravel, (*1)
composer require aharen/cart
Add CartServiceProvider to providers in config/app.php, (*2)
aharen\Cart\CartServiceProvider::class,, (*3)
Add Cart Facade to aliases in config/app.php, (*4)
'Cart' => aharen\Cart\CartFacade::class,, (*5)
Publish the config file to config folder, (*6)
php artisan vendor:publish, (*7)
If so some reason it doesn't create the config file you have to create a file named cart.php inside the config folder with the contents below, (*8)
<?php
return [
'name' => 'yourcartnamehere',
];
Get the current contents of the cart. Will return false if the cart is empty, (*9)
Cart::get();
Cart::count();
The first parameter is your item. It can either be an ID or item name. The second parameter has to be numeric which is the Quantity., (*10)
Cart::add('Pizza Slice', 2);
Accepts only 1 parameter, which is your item ID or item name, (*11)
Cart::remove('Pizza Slice');
Empties your current cart, (*12)
Cart::reset();