public function sell($count) { $this->count -= $count; foreach (ProductPackage::selection(array('package' => $this->id)) as $package) { $product = $package->Product(); $product->sell($count * $package->count); } $this->commit(); }
<?php $product = Product::from_id(array_shift($request)); if (!$product) { die('unknown product'); } $packages = ProductPackage::selection(array('package' => $product->id)); $total = $product->value; ?> <table> <tr> <th>Namn</th> <td><?php echo $product->name; ?> </td> </tr> <tr> <th>Status</th> <td><?php echo $product->active ? 'Aktiv' : 'Inaktiv'; ?> </td> </tr> <tr> <th>Pris</th> <td><?php echo $product->price; ?> </td> </tr>