public function addAssemblyItem(Model $part, $quantity = 1, array $extra = [])
{
if ($this->isValidQuantity($quantity)) {
if (!$this->getAttribute('is_assembly')) {
$this->makeAssembly();
}
if ($part->getAttribute('is_assembly')) {
$this->validatePart($part);
}
$attributes = array_merge(['quantity' => $quantity], $extra);
if ($this->assemblies()->save($part, $attributes)) {
$this->fireEvent('inventory.assembly.part-added', ['item' => $this, 'part' => $part]);
$this->forgetCachedAssemblyItems();
return $this;
}
}
return false;
}