PHPackages                             rayjun/laravel-cart - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. rayjun/laravel-cart

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

rayjun/laravel-cart
===================

Cart for Laravel Application.

v1.0.8(11y ago)4261MITPHP

Since Jul 25Pushed 11y ago1 watchersCompare

[ Source](https://github.com/rayjun/laravel-cart)[ Packagist](https://packagist.org/packages/rayjun/laravel-cart)[ RSS](/packages/rayjun-laravel-cart/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (5)Versions (10)Used By (0)

laravel-cart
============

[](#laravel-cart)

laravel 框架购物车组件

安装
==

[](#安装)

可以直接在命令行安装：

```
composer require "rayjun/laravel-cart:1.0.*"

```

或者可以在你项目的 `composer.json`

```
"require": {
     "rayjun/laravel-cart": "1.0.*"
}

```

然后执行：

```
composer update

```

在完成上面的步骤之后，可以在 `config/app.php` 的 `providers` 数组中增加以下的代码:

```
'Rayjun\LaravelCart\LaravelCartServiceProvider'

```

然后增加下面一行到 `aliases`:

```
'Cart'   => 'Rayjun\LaravelCart\Facades\Cart',

```

使用
==

[](#使用)

获取一个购物车
-------

[](#获取一个购物车)

```
Cart Cart::cart(int $user_id);

```

增加商品进购物车
--------

[](#增加商品进购物车)

```
CartItem Cart::add(int $cart_id, int $good_id, int $count, float $price, string color, string size);

```

更新一件商品的属性
---------

[](#更新一件商品的属性)

```
CartItem Cart::updateItem(int $item_id, array $attributes);
CartItem Cart::updateQty(int $item_id, int $qty);

```

获取购物车中所有的商品信息
-------------

[](#获取购物车中所有的商品信息)

```
Collection Cart::getAllItems(int $cart_id);

```

获取一个特定的商品项
----------

[](#获取一个特定的商品项)

```
CartItem Cart::getItem(int $item_id);

```

删除一个特定的商品项
----------

[](#删除一个特定的商品项)

```
boolean Cart::removeItem(int $item_id);

```

清空购物车
-----

[](#清空购物车)

```
boolean Cart::removeAllItem(int $cart_id);

```

购物车总价
-----

[](#购物车总价)

```
float Cart::totalPrice(int $cart_id);

```

购物车总商品数
-------

[](#购物车总商品数)

```
int Cart::count(int $cart_id);

```

###  Health Score

31

—

LowBetter than 65% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

9

Last Release

4039d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7517993?v=4)[rayoo](/maintainers/rayjun)[@rayjun](https://github.com/rayjun)

---

Top Contributors

[![rayjun](https://avatars.githubusercontent.com/u/7517993?v=4)](https://github.com/rayjun "rayjun (11 commits)")

---

Tags

laravelcart

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rayjun-laravel-cart/health.svg)

```
[![Health](https://phpackages.com/badges/rayjun-laravel-cart/health.svg)](https://phpackages.com/packages/rayjun-laravel-cart)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k161.4k2](/packages/mike-bronner-laravel-model-caching)[laravel/ai

The official AI SDK for Laravel.

1.1k4.6M322](/packages/laravel-ai)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

265.2k](/packages/aedart-athenaeum)[propaganistas/laravel-disposable-email

Disposable email validator

6023.2M7](/packages/propaganistas-laravel-disposable-email)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
