Renamed migration file

Fixed migration being published multiple times
Added more tests
Fixed setGlobalTax and setGlobalDiscount
This commit is contained in:
Patrick Henninger
2018-12-23 23:24:05 +01:00
parent 8615c1131f
commit 3ebe09f6ab
4 changed files with 52 additions and 12 deletions

View File

@@ -459,8 +459,10 @@ class Cart
public function setGlobalTax($taxRate)
{
$this->taxRate = $taxRate;
if ($this->content && $this->content->count()) {
$this->content->each(function ($item, $key) {
$content = $this->getContent();
if ($content && $content->count()) {
$content->each(function ($item, $key) {
$item->setTaxRate($this->taxRate);
});
}
@@ -495,8 +497,10 @@ class Cart
public function setGlobalDiscount($discount)
{
$this->discount = $discount;
if ($this->content && $this->content->count()) {
$this->content->each(function ($item, $key) {
$content = $this->getContent();
if ($content && $content->count()) {
$content->each(function ($item, $key) {
$item->setDiscountRate($this->discount);
});
}

View File

@@ -29,13 +29,8 @@ class ShoppingcartServiceProvider extends ServiceProvider
}
});
if ( ! class_exists('CreateShoppingcartTable')) {
// Publish the migration
$timestamp = date('Y_m_d_His', time());
$this->publishes([
__DIR__.'/../database/migrations/0000_00_00_000000_create_shoppingcart_table.php' => database_path('migrations/'.$timestamp.'_create_shoppingcart_table.php'),
], 'migrations');
}
$this->publishes([
realpath(__DIR__.'/../database/migrations') => $this->app->databasePath().'/migrations'
]);
}
}