public function onSave() { $product = Product::findOrFail($this->param('id')); $attributes = array('category', 'quantity', 'quantity_UM'); foreach ($attributes as $attr) { $key = sprintf("%s.%s", $product->id, $attr); $attribute = ModelProductAttributes::firstOrNew(['id' => $key]); $attribute->key = $attr; $attribute->value = post($attr); $attribute->save(); } }
public function onRun() { $this->product = Product::findOrFail($this->param('id')); $this->addCss("styles/index.css"); return parent::onRun(); }