clphillips / seedling

A framework agnostic database seeding and fixture library
MIT License
0 stars 0 forks source link

Add generateKey to \Seedling\Drivers\DriverInterface #23

Closed clphillips closed 9 years ago

clphillips commented 9 years ago

It may be necessary to access the key for a particular label. For instance:

products id, name, price

inventory id, number, qty

Where inventory.number is composed of ID + products.id. Assume products.id =123, then inventory.number = ID123.

Here's how we we'd implement that in the seed file:

<?php
return [
    'inventory.123' => [
        'number' => function () {
            return 'ID' . Fixture::getInstance()->getDriver()
                ->generateKey('123', 'products');
        }
    ]
];