Stevebauman\Inventory\Traits\InventoryTrait::processSkuGeneration PHP Метод

processSkuGeneration() защищенный Метод

Processes an SKU generation covered by database transactions.
protected processSkuGeneration ( integer | string $inventoryId, string $code ) : boolean | mixed
$inventoryId integer | string
$code string
Результат boolean | mixed
    protected function processSkuGeneration($inventoryId, $code)
    {
        $this->dbStartTransaction();
        try {
            $sku = $this->sku()->getRelated()->newInstance();
            $sku->setAttribute('inventory_id', $inventoryId);
            $sku->setAttribute('code', $code);
            if ($sku->save()) {
                $this->dbCommitTransaction();
                $this->fireEvent('inventory.sku.generated', ['item' => $this, 'sku' => $sku]);
                return $sku;
            }
        } catch (\Exception $e) {
            $this->dbRollbackTransaction();
        }
        return false;
    }