public function createSku($code, $overwrite = false)
{
// Get the current SKU record
$sku = $this->sku()->first();
if ($sku) {
// The dev doesn't want the SKU overridden, we'll thrown an exception
if (!$overwrite) {
$message = Lang::get('inventory::exceptions.SkuAlreadyExistsException');
throw new SkuAlreadyExistsException($message);
}
// Overwrite is true, lets update the current SKU
return $this->updateSku($code, $sku);
}
// No SKU exists, lets create one
return $this->processSkuGeneration($this->getKey(), $code);
}