Skip to content

Commit

Permalink
Upcoming 2.0 (#4)
Browse files Browse the repository at this point in the history
* Update Code in general

* Make travis runnable

* Update docs

* Fix unittest
  • Loading branch information
darthsoup authored Mar 8, 2018
1 parent 4c8cd43 commit e225f01
Show file tree
Hide file tree
Showing 22 changed files with 551 additions and 603 deletions.
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
language: php

php:
- 7.0
- 7.1
- 7.2

before_script:
- composer self-update
- composer install --prefer-source --no-interaction --dev

script: phpunit
script: phpunit

cache:
directories:
- $HOME/.cache/composer
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ $ vendor/bin/phpunit

If the test suite passes on your local machine you should be good to go.

When you make a pull request, the tests will automatically be run again by [Travis CI](https://travis-ci.org/) on multiple php versions and hhvm.
When you make a pull request, the tests will automatically be run again by [Travis CI](https://travis-ci.org/) on multiple php versions.
3 changes: 3 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
The MIT License (MIT)

Copyright (c) 2016 Rob Gloudemans <[email protected]>
Copyright (c) 2018 Kevin Krummnacker <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
Expand Down
54 changes: 31 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
## Laravel Cart

[![Build Status](https://travis-ci.org/darthsoup/laravel-shoppingcart.svg?branch=master)](https://travis-ci.org/darthsoup/laravel-shopsauceart)
[![Build Status](https://travis-ci.org/darthsoup/laravel-shoppingcart.svg?branch=master)](https://travis-ci.org/darthsoup/laravel-shoppingcart)
[![Total Downloads](https://poser.pugx.org/darthsoup/shoppingcart/downloads)](https://packagist.org/packages/darthsoup/shoppingcart)

An easy shoppingcart implementation for Laravel > 5.2 based on Gloudemans\Shoppingcart.
An easy shoppingcart implementation for Laravel > 5.2.
Based on the work of Gloudemans\Shoppingcart.

## Features

This package for shopping carts provides these features:

* Cart items can have subitems
* Individual taxing for single items //todo
* Custom hash algorithms for item identifiers //todo
* Database Support //todo
* Unit tests //todo
* Custom hash algorithms for item identifiers
* Individual taxing for single items # todo
* Database Support # todo

## Installation

Install the package through [Composer](http://getcomposer.org/). Edit your project's `composer.json` file by adding:

### Requirements

This package needs at least Laravel 5.2 and PHP 7.0. It may be running on older version like Laravel 5.1 or 5.0 but it is untested.
This package needs at least Laravel 5.2 and PHP 7.1.

### Install

Expand All @@ -31,6 +31,12 @@ First, you'll need to install the package via Composer:
$ composer require darthsoup/shoppingcart
```

### After Laravel 5.5

You do not need to do anything else here

### Before Laravel 5.5

Then, update `config/app.php` by adding an entry for the service provider.

```php
Expand Down Expand Up @@ -90,12 +96,17 @@ Cart::add($item);

### Update one Item

TODO
```php
Cart::update('rowId', [
'options' => [$field => $value]
]);
```

### Get One Cart Item

TODO

```php
Cart::get('rowId');
```

### Show Cart Content

Expand All @@ -113,7 +124,9 @@ Cart::destroy();

### Remove one Item

TODO
```php
Cart::remove('rowId');
```

### Total Price of all Items

Expand All @@ -124,14 +137,9 @@ Cart::total();
### Item Count

```php

Cart::count();
Cart::count();
```

### Item Search

TODO

## SubItems

This package also includes the functionality to add Subitems by adding them to an additional Collection in the Item
Expand All @@ -142,17 +150,17 @@ The `addSubItem` function works basically like `add` but it accepts a parent row
to the item.

```php
Cart::add('15', 'Hamburger', 1, 1.99, ['onion' => false]);
$hamburger = Cart::add('15', 'Hamburger', 1, 1.99, ['onion' => false]);

Cart::addSubItem('99', 'Extra Bacon', 1, 0.99, [], $hamburger->getRowId())
```

### Remove SubItem

TODO

Just like removing normal ones, just include your subItem `rowId` and it will be removed from the parent

## Models

A new feature is associating a model with the items in the cart. Let's say you have a `Product` model in your application. With the `associate()` method, you can tell the cart that an item in the cart, is associated to the `Product` model.

That way you can access your model right from the `CartCollection`!
Expand All @@ -179,7 +187,8 @@ The Cart package will throw exceptions if something goes wrong. This way it's ea
| ------------------------------------- | --------------------------------------------------------------------------------- |
| *InstanceException* | When no instance is passed to the instance() method |
| *InvalidRowIdException* | When the `$rowId` that got passed doesn't exists in the current cart |
| *ClassNotFoundException* | When an class cannot found while association |
| *InvalidQuantityException* | When the quantity is outside the set limits |
| *ClassNotFoundException* | When an class cannot found while association |

## Events

Expand All @@ -188,8 +197,7 @@ The cart also has events build in. There are five events available for you to li
| Event | Fired |
| ------------------------------ | --------------------------------------- |
| cart.added($item) | When a item is added |
| cart.subitem.added($item) | When a sub item is added |
| cart.subitem.removed($item) | When a sub item is added |
| cart.subitem.added($item) | When a sub item is added | |
| cart.updated($rowId) | When an item in the cart is updated |
| cart.removed($rowId) | When an item is removed from the cart |
| cart.destroyed() | When the cart is destroyed |
Expand Down
18 changes: 11 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,32 @@
"keywords": ["laravel", "shoppingcart"],
"license": "MIT",
"authors": [
{
"name": "Rob Gloudemans",
"email": "[email protected]"
},
{
"name": "Kevin Krummmnacker",
"email": "[email protected]"
}
],
"require": {
"php": ">=7.0.0",
"illuminate/support": "5.2.*|5.3.*|5.4.*|5.5.*|5.6.*"
"illuminate/support": "5.2.*|5.3.*|5.4.*|5.5.*|5.6.*",
"illuminate/session": "5.2.*|5.3.*|5.4.*|5.5.*|5.6.*",
"illuminate/events": "5.2.*|5.3.*|5.4.*|5.5.*|5.6.*"
},
"require-dev": {
"mockery/mockery": "~0.9",
"phpunit/phpunit": "~5.0|~6.0"
"mockery/mockery": "~1.0",
"phpunit/phpunit": "~6.0|~7.0",
"orchestra/testbench": "~3.2"
},
"autoload": {
"psr-4": {
"DarthSoup\\Cart\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"DarthSoup\\Tests\\Cart\\": "tests/"
}
},
"minimum-stability": "stable",
"extra": {
"laravel": {
Expand Down
19 changes: 19 additions & 0 deletions config/cart.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| Tax
|--------------------------------------------------------------------------
*/
'tax' => 19,

/*
|--------------------------------------------------------------------------
| Item Hash
|--------------------------------------------------------------------------
*/
'hasher' => \DarthSoup\Cart\Hashes\Md5::class,

];
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
syntaxCheck="false"
>
<testsuites>
<testsuite name="Package Test Suite">
<testsuite name="Cart Test Suite">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
Expand Down
Loading

0 comments on commit e225f01

Please sign in to comment.