|
14 | 14 | - [Publish](#publish) |
15 | 15 | - [Usage](#usage) |
16 | 16 | - [Configuration](#configuration) |
17 | | - - [Store Cart](#store-cart) |
18 | | - - [Access Itemable](#access-itemable) |
19 | | - - [Create Cart With Storing Items](#create-cart-with-storing-item) |
20 | | - - [Store multiple items](#store-multiple-items) |
21 | | - - [Store Item For a Cart](#store-item-for-a-cart) |
22 | | - - [Delete Item From Cart](#delete-item-from-cart) |
23 | | - - [Delete All Items From Cart](#delete-all-items-from-cart) |
24 | | - - [Increase Quantity](#increase-quantity) |
25 | | - - [Decrease Quantity](#decrease-quantity) |
| 17 | + - [Laravel Cart Facade](#laravel-cart-facade) |
| 18 | + - [Driver](#driver) |
| 19 | + - [Support Drivers](#support-drivers) |
| 20 | + - [Laravel Cart Model](#laravel-cart-model) |
| 21 | + - [Store Cart](#store-cart) |
| 22 | + - [Access Itemable](#access-itemable) |
| 23 | + - [Create Cart With Storing Items](#create-cart-with-storing-item) |
| 24 | + - [Store multiple items](#store-multiple-items) |
| 25 | + - [Store Item For a Cart](#store-item-for-a-cart) |
| 26 | + - [Delete Item From Cart](#delete-item-from-cart) |
| 27 | + - [Delete All Items From Cart](#delete-all-items-from-cart) |
| 28 | + - [Increase Quantity](#increase-quantity) |
| 29 | + - [Decrease Quantity](#decrease-quantity) |
26 | 30 | - [Contributors](#contributors) |
27 | 31 | - [Security](#security) |
28 | 32 | - [Changelog](#changelog) |
@@ -87,6 +91,49 @@ After publishing, run the `php artisan migrate` command. |
87 | 91 |
|
88 | 92 | You can config the `Laravel Cart` with `laravel-cart.php` config that exists in `config` folder. |
89 | 93 |
|
| 94 | +<a name="laravel-cart-facade"></a> |
| 95 | +### Laravel Cart Facade |
| 96 | + |
| 97 | +For convenience, you can use Laravel Cart facade to store, delete, and ...: |
| 98 | + |
| 99 | +```php |
| 100 | +<?php |
| 101 | + |
| 102 | +use Binafy\LaravelCart\LaravelCart; |
| 103 | + |
| 104 | +LaravelCart::driver('session')->storeItem($item, $userId|null); |
| 105 | +LaravelCart::storeItem($item $userId|null); |
| 106 | +``` |
| 107 | + |
| 108 | +<a name="driver"></a> |
| 109 | +### Driver |
| 110 | + |
| 111 | +If you may to using Laravel Cart facade, you can change the driver for store, delete, and ...: |
| 112 | + |
| 113 | +```php |
| 114 | +<?php |
| 115 | + |
| 116 | +use Binafy\LaravelCart\LaravelCart; |
| 117 | + |
| 118 | +LaravelCart::driver('database')->storeItem($item, $userId|null); |
| 119 | +LaravelCart::driver('session')->removeItem($item); |
| 120 | +``` |
| 121 | + |
| 122 | +> The default driver is `database` and if you would to change the driver, you need to use the Laravel Cart config file that exists on `config\laravel-cart.php`. |
| 123 | +
|
| 124 | +<a name="support-drivers"></a> |
| 125 | +### Support Drivers |
| 126 | + |
| 127 | +| Drivers | Name | |
| 128 | +|----------|----------| |
| 129 | +| Session | session | |
| 130 | +| Database | database | |
| 131 | + |
| 132 | +<a name="laravel-cart-model"></a> |
| 133 | +### Laravel Cart Model |
| 134 | + |
| 135 | +Also, you are able to use Laravel Cart models for fetch or ... with Laravel Eloquent. |
| 136 | + |
90 | 137 | <a name="store-cart"></a> |
91 | 138 | ### Store Cart |
92 | 139 |
|
|
0 commit comments