PHPackages                             lacernest/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. lacernest/laravel-cart

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

lacernest/laravel-cart
======================

Laravel Cart is designed to be highly customizable and flexible, making it easy to adapt to your specific use case.

00PHP

Since Jun 22Pushed 1y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Cart
============

[](#laravel-cart)

[![lacernest-laravel-cart](https://camo.githubusercontent.com/49c8411beafa999bbae3d83951ccef5c2a61660db3d52ac16440e11b563f0a26/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c253230436172742e706e673f7468656d653d6461726b267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d6c616365726e6573742532466c61726176656c2d63617274267061747465726e3d617574756d6e267374796c653d7374796c655f31266465736372697074696f6e3d637573746f6d697a61626c652b7061636b6167652b666f722b616464696e672b73686f7070696e672b636172742b66756e6374696f6e616c6974792b746f2b4c61726176656c2b6170706c69636174696f6e73266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667)](https://camo.githubusercontent.com/49c8411beafa999bbae3d83951ccef5c2a61660db3d52ac16440e11b563f0a26/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c253230436172742e706e673f7468656d653d6461726b267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d6c616365726e6573742532466c61726176656c2d63617274267061747465726e3d617574756d6e267374796c653d7374796c655f31266465736372697074696f6e3d637573746f6d697a61626c652b7061636b6167652b666f722b616464696e672b73686f7070696e672b636172742b66756e6374696f6e616c6974792b746f2b4c61726176656c2b6170706c69636174696f6e73266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667)

[![PHP Version Require](https://camo.githubusercontent.com/a824a1894f27722257a9d76339767b72d1c8eea7799bf30edafab498715c3baa/687474703a2f2f706f7365722e707567782e6f72672f6c616365726e6573742f6c61726176656c2d636172742f726571756972652f706870)](https://packagist.org/packages/lacernest/laravel-cart)[![Latest Stable Version](https://camo.githubusercontent.com/f8132715f1176c87fe4c4de28e2f5d2f3b93a3183a87786c2bd65f73b7ad4248/687474703a2f2f706f7365722e707567782e6f72672f6c616365726e6573742f6c61726176656c2d636172742f76)](https://packagist.org/packages/lacernest/laravel-cart)[![Total Downloads](https://camo.githubusercontent.com/49153132f41f988ccc6be36e32623c5592273a15994d9e5d44b732659681808e/687474703a2f2f706f7365722e707567782e6f72672f6c616365726e6573742f6c61726176656c2d636172742f646f776e6c6f616473)](https://packagist.org/packages/lacernest/laravel-cart)[![License](https://camo.githubusercontent.com/116593ee311d30a9efde603c657fceb58aaff9087e350b1c0f7ed3ced13b4def/687474703a2f2f706f7365722e707567782e6f72672f6c616365726e6573742f6c61726176656c2d636172742f6c6963656e7365)](https://packagist.org/packages/lacernest/laravel-cart)[![Passed Tests](https://github.com/lacernest/laravel-cart/actions/workflows/tests.yml/badge.svg)](https://github.com/lacernest/laravel-cart/actions/workflows/tests.yml)

Introduction
------------

[](#introduction)

The `Laravel Cart` is a highly customizable and flexible package that integrates basket functionality into your Laravel application. It simplifies storing and managing cart items, supporting multiple item types and quantities. It is ideal for e-commerce platforms to create carts, attach items, and manage them efficiently. Installation is straightforward via Composer, and it offers robust features like secure item storage, easy cart manipulation, and seamless integration with your existing Laravel app.

Features:
---------

[](#features)

- Secure card information storage and management
- Support for multiple payment gateways
- Recurring payment and subscription management
- Robust validation and error handling
- Highly customizable and flexible architecture

Installation
------------

[](#installation)

You can install the package with Composer:

```
composer require lacernest/laravel-cart
```

Publish
-------

[](#publish)

If you want to publish a config file, you can use this command:

```
php artisan vendor:publish --tag="laravel-cart-config"
```

If you want to publish the migrations, you can use this command:

```
php artisan vendor:publish --tag="laravel-cart-migrations"
```

For convenience, you can use this command to publish config, migration, and ... files:

```
php artisan vendor:publish --provider="LacErnest\LaravelCart\Providers\LaravelCartServiceProvider"
```

After publishing, run the `php artisan migrate` command.

Usage
-----

[](#usage)

### Store Cart

[](#store-cart)

For storing a new cart, you can use `Cart` model:

```
use \LacErnest\LaravelCart\Models\Cart;

$cart = Cart::query()->firstOrCreate(['user_id' => $user->id]);
```

### Store Items For a Cart

[](#store-items-for-a-cart)

If you want to store items for cart, first you need to create a cart and attach items to cart:

```
$cart = Cart::query()->firstOrCreate(['user_id' => $user->id]);
$cartItem = new CartItem([
    'itemable_id' => $itemable->id,
    'itemable_type' => $itemable::class,
    'quantity' => 1,
]);

$cart->items()->save($cartItem);
```

If you may to access the items of one cart, you can use `items` relation that exists in Cart model.

> There is no need to use any Interface or something for itemable.

### Access Itemable

[](#access-itemable)

If you want to access to itemable in `CartItem`, you can use `itemable` relation:

```
$cartItem = new CartItem([
    'itemable_id' => $itemable->id,
    'itemable_type' => $itemable::class,
    'quantity' => 1,
]);

$cartItem->itemable()->first(); // Return Model Instance
```

### Create Cart With Storing Items

[](#create-cart-with-storing-items)

```
Cart::query()->firstOrCreateWithStoreItems(
    item: $product,
    quantity: 1,
    userId: $user->id
);
```

### Store multiple items

[](#store-multiple-items)

If you may to store multiple items for a cart, you can use `storeItems` method:

```
$items = [
    [
        'itemable' => $product1,
        'quantity' => 2,
    ],
    [
        'itemable' => $product2,
        'quantity' => 1,
    ],
    [
        'itemable' => $product3,
        'quantity' => 5,
    ],
];

$cart = Cart::query()->firstOrCreate(['user_id' => $user->id]);
$cart->storeItems($items);
```

Security
--------

[](#security)

If you discover any security-related issues, please email `ernestsamo16@gmail.com` instead of using the issue tracker.

Changelog
---------

[](#changelog)

The changelog can be found in the `CHANGELOG.md` file of the GitHub repository. It lists the changes, bug fixes, and improvements made to each version of the Laravel User Monitoring package.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/lacernest/laravel-cart/blob/0.x-dev/LICENSE) for more information.

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/a8a9895c47a1443bb05f5ac12bb4f301ef881bba069b8c3b827a6cb20e692c66?d=identicon)[LacErnest](/maintainers/LacErnest)

---

Top Contributors

[![LacErnest](https://avatars.githubusercontent.com/u/17462487?v=4)](https://github.com/LacErnest "LacErnest (1 commits)")

### Embed Badge

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

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

###  Alternatives

[ddeboer/tesseract

A wrapper for the Tesseract OCR engine

23135.1k](/packages/ddeboer-tesseract)

PHPackages © 2026

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