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(10y ago)4261MITPHP

Since Jul 25Pushed 10y 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 1mo 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 68% 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

3947d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/234d216a029cba9368022444279173d49fd40a2955ee190c05304528f0c49f36?d=identicon)[rayjun](/maintainers/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

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[spatie/laravel-enum

Laravel Enum support

3655.4M31](/packages/spatie-laravel-enum)[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)

PHPackages © 2026

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