Added ProductNetwork
This commit is contained in:
@@ -23,6 +23,7 @@ class ProductController extends mfBaseController {
|
||||
$this->layout()->set("productgroups", ProductgroupModel::getAll());
|
||||
$this->layout()->set("producttechs", ProducttechModel::getAll());
|
||||
$this->layout()->set("slas", SlaModel::getAll());
|
||||
$this->layout()->set("networks", NetworkModel::getAll());
|
||||
|
||||
}
|
||||
|
||||
@@ -96,6 +97,24 @@ class ProductController extends mfBaseController {
|
||||
return $this->add();
|
||||
}
|
||||
|
||||
// delete all networks to save networks
|
||||
$pnets = ProductNetworkModel::search(['product_id' => $new_id]);
|
||||
foreach($pnets as $pnet) {
|
||||
$pnet->delete();
|
||||
}
|
||||
|
||||
if(is_array($r->networks) && count($r->networks)) {
|
||||
foreach($r->networks as $network_id) {
|
||||
$network = new Network($network_id);
|
||||
if(!$network->id) {
|
||||
// ignore non-existing networks
|
||||
continue;
|
||||
}
|
||||
$pnet = ProductNetworkModel::create(['product_id' => $new_id, 'network_id' => $network_id]);
|
||||
$pnet->save();
|
||||
}
|
||||
}
|
||||
|
||||
// create new product group and tech
|
||||
|
||||
if($r->productgroup_id == "new") {
|
||||
|
||||
Reference in New Issue
Block a user