Download the PHP package mohammadv184/laravel-cart without Composer

On this page you can find all versions of the php package mohammadv184/laravel-cart. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-cart

laravel-cart

Latest Stable Version Total Downloads Monthly Downloads Build Status License

A Shoping Cart for Laravel Framework

Installation

Install the package through Composer.

Run the Composer require command from the Terminal:

composer require mohammadv184/laravel-cart

If you're using Laravel 5.5, this is all there is to do.

Should you still be on version 5.4 of Laravel, the final steps for you are to add the service provider of the package and alias the package. To do this open your config/app.php file.

Add a new line to the providers array:

Mohammadv184\Cart\CartProvider::class

And optionally add a new line to the aliases array:

'Cart' => Mohammadv184\Cart\Facades\Cart::class,

Now you're ready to start using the laravel-cart in your application.

Database

To save cart into the database, the package needs to know which what the name of the table is. By default the package will use a table named cart_items. If you want to change these options, you'll have to publish the config file.

php artisan vendor:publish --provider="Mohammadv184\Cart\CartServiceProvider" --tag="config"

This will give you a cart.php config file in which you can make the changes.

To make your life easy, the package also includes a ready to use migration which you can publish by running:

php artisan vendor:publish --provider="Mohammadv184\Cart\CartServiceProvider" --tag="migrations"

This will place a cart_items table's migration file into database/migrations directory. Now all you have to do is run php artisan migrate to migrate your database.

Overview

Look at one of the following topics to learn more about Laravel-cart

Usage

The laravel-cart gives you the following methods to use:

Cart::put()

Adding an item to the cart is really simple, you just use the put() method, which accepts a variety of parameters.

In its most basic form you can specify the quantity, price and product model of the product you'd like to add to the cart.

Cart::update()

To update an item in the cart, you'll first need the rowId of the item. Next you can use the update() method to update it.

If you simply want to update the quantity, you'll pass the update method the product model or id and the new quantity:

OR

If you want to update more attributes of the item, you can either pass the update method an array as the first parameter. This way you can update all information of the item with the given id.

Cart::delete()

To delete an item for the cart, you'll again need the product model or id. This id you simply pass to the delete() method and it will delete the item from the cart.

OR

Cart::get()

If you want to get an item from the cart using its id or product model, you can simply call the get() method on the cart and pass it the id or product model.

OR

Cart::all()

Of course you also want to get the all items in cart. This is where you'll use the all method. This method will return a Collection of Cart Items.

Cart::flush()

If you want to completely delete the all items of a cart, you can call the flush method on the cart. This will delete all Cart Items from the cart for the current cart instance.

Cart::totalPrice()

The totalPrice() method can be used to get the totalPrice of all items in the cart.

Example

Below is a little example of how to list the cart content in a table:


All versions of laravel-cart with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3
laravel/framework Version 5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|^6.0|^7.0|^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mohammadv184/laravel-cart contains the following files

Loading the files please wait ....