Skip to content

Commit 0f20bef

Browse files
committed
Large update for version 2.0
1 parent f5f15c7 commit 0f20bef

35 files changed

+1820
-1133
lines changed

.gitignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/vendor
22
composer.phar
33
composer.lock
4-
.DS_Store
5-
.idea
4+
.DS_Store

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ php:
44
- 5.4
55
- 5.5
66
- 5.6
7+
- 7.0
78

89
before_script:
910
- composer self-update

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2014 Rob Gloudemans <[email protected]>
3+
Copyright (c) 2016 Rob Gloudemans <[email protected]>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+8-26
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,25 @@
22
[![Build Status](https://travis-ci.org/Crinsane/LaravelShoppingcart.png?branch=master)](https://travis-ci.org/Crinsane/LaravelShoppingcart)
33
[![Total Downloads](https://poser.pugx.org/gloudemans/shoppingcart/downloads.png)](https://packagist.org/packages/gloudemans/shoppingcart)
44

5-
A simple shoppingcart implementation for Laravel 4.
5+
A simple shoppingcart implementation for Laravel.
66

77
## Installation
88

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

11-
### Laravel 4.2 and below
11+
Run the Composer require command from the Terminal:
1212

13-
```php
14-
"require": {
15-
"laravel/framework": "4.2.*",
16-
"gloudemans/shoppingcart": "~1.2"
17-
}
18-
```
19-
20-
### Laravel 5
21-
22-
```php
23-
"require": {
24-
"laravel/framework": "5.0.*",
25-
"gloudemans/shoppingcart": "~1.3"
26-
}
27-
```
28-
29-
Next, run the Composer update command from the Terminal:
30-
31-
composer update
13+
composer require gloudemans/shoppingcart
3214

33-
Now all you have to do is add the service provider of the package and alias the package. To do this open your `app/config/app.php` file.
15+
Now all you have to do is add the service provider of the package and alias the package. To do this open your `config/app.php` file.
3416

3517
Add a new line to the `service providers` array:
3618

37-
'Gloudemans\Shoppingcart\ShoppingcartServiceProvider'
19+
\Gloudemans\Shoppingcart\ShoppingcartServiceProvider::class
3820

39-
And finally add a new line to the `aliases` array:
21+
And optionally add a new line to the `aliases` array:
4022

41-
'Cart' => 'Gloudemans\Shoppingcart\Facades\Cart',
23+
'Cart' => \Gloudemans\Shoppingcart\Facades\Cart::class,
4224

4325
Now you're ready to start using the shoppingcart in your application.
4426

composer.json

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
{
22
"name": "gloudemans/shoppingcart",
3-
"description": "Laravel 5 Shoppingcart",
3+
"description": "Laravel Shoppingcart",
44
"keywords": ["laravel", "shoppingcart"],
55
"license": "MIT",
66
"authors": [
77
{
88
"name": "Rob Gloudemans",
9-
"email": "[email protected]"
9+
"email": "[email protected]"
1010
}
1111
],
1212
"require": {
13-
"php": ">=5.4.0",
14-
"illuminate/support": "~5.0"
13+
"illuminate/support": "5.2.*",
14+
"illuminate/session": "^5.2.*",
15+
"illuminate/events": "^5.2.*"
1516
},
1617
"require-dev": {
17-
"mockery/mockery": "~0.9",
18-
"phpunit/phpunit": "~4.0"
19-
},
20-
"suggest": {
21-
"gloudemans/notify": "Simple flash notifications for Laravel 5"
18+
"phpunit/phpunit": "~4.0",
19+
"mockery/mockery": "~0.9.0",
20+
"orchestra/testbench": "~3.0"
2221
},
2322
"autoload": {
24-
"psr-0": {
25-
"Gloudemans\\Shoppingcart": "src/"
23+
"psr-4": {
24+
"Gloudemans\\Shoppingcart\\": "src/"
2625
}
2726
},
27+
"suggest": {
28+
"gloudemans/notify": "Simple flash notifications for Laravel"
29+
},
2830
"minimum-stability": "dev"
2931
}

config/cart.php

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
return [
4+
5+
/*
6+
|--------------------------------------------------------------------------
7+
| Default tax rate
8+
|--------------------------------------------------------------------------
9+
|
10+
| This default tax rate will be used when you make a class implement the
11+
| Taxable interface and use the HasTax trait.
12+
|
13+
*/
14+
'tax' => 21
15+
16+
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Schema;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Database\Migrations\Migration;
6+
7+
class CreateShoppingcartTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up()
13+
{
14+
Schema::create('shoppingcart', function (Blueprint $table) {
15+
$table->string('identifier');
16+
$table->string('instance');
17+
$table->longText('content');
18+
$table->nullableTimestamps();
19+
20+
$table->primary(['identifier', 'instance']);
21+
});
22+
}
23+
/**
24+
* Reverse the migrations.
25+
*/
26+
public function down()
27+
{
28+
Schema::drop('shoppingcart');
29+
}
30+
}

phpunit.xml

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
convertWarningsToExceptions="true"
99
processIsolation="false"
1010
stopOnFailure="false"
11-
syntaxCheck="false"
12-
>
11+
syntaxCheck="false">
1312
<testsuites>
1413
<testsuite name="Package Test Suite">
1514
<directory suffix=".php">./tests/</directory>

src/CanBeBought.php

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace Gloudemans\Shoppingcart;
4+
5+
trait CanBeBought
6+
{
7+
8+
/**
9+
* Get the identifier of the Buyable item.
10+
*
11+
* @return int|string
12+
*/
13+
public function getBuyableIdentifier()
14+
{
15+
return method_exists($this, 'getKey') ? $this->getKey() : $this->id;
16+
}
17+
18+
/**
19+
* Get the description or title of the Buyable item.
20+
*
21+
* @return string
22+
*/
23+
public function getBuyableDescription()
24+
{
25+
if(property_exists('name', $this)) return $this->name;
26+
if(property_exists('title', $this)) return $this->title;
27+
if(property_exists('description', $this)) return $this->description;
28+
29+
return null;
30+
}
31+
32+
/**
33+
* Get the price of the Buyable item.
34+
*
35+
* @return float
36+
*/
37+
public function getBuyablePrice()
38+
{
39+
if(property_exists('price', $this)) return $this->price;
40+
41+
return null;
42+
}
43+
}

0 commit comments

Comments
 (0)