Changeset View
Changeset View
Standalone View
Standalone View
src/app/Observers/PackageSkuObserver.php
- This file was added.
<?php | |||||
namespace App\Observers; | |||||
class PackageSkuObserver | |||||
{ | |||||
public function created(\App\PackageSku $packageSku) | |||||
{ | |||||
// TODO: free units... | |||||
$package = $packageSku->package; | |||||
$sku = $packageSku->sku; | |||||
$cost = ($sku->cost * (100 - $package->discount_rate)) / 100; | |||||
\Log::debug("Setting costs for {$sku->title} on package {$package->title} to {$cost}"); | |||||
$package->skus()->updateExistingPivot( | |||||
$sku, | |||||
['cost' => ($sku->cost * (100 - $package->discount_rate)) / 100], | |||||
machniak: You calculated this a few lines above. | |||||
vanmeeuwenAuthorUnsubmitted Done Inline Actionshihi, indeed, because of the superfluous debug ;-) vanmeeuwen: hihi, indeed, because of the superfluous debug ;-) | |||||
false | |||||
); | |||||
} | |||||
} |
You calculated this a few lines above.