Created
December 7, 2017 10:12
-
-
Save jaynarayan89/86874a0926a513849bf0e1dddf5145d1 to your computer and use it in GitHub Desktop.
fakecakeseeder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Migrations\AbstractSeed; | |
/** | |
* Customers seed. | |
*/ | |
class CustomersSeed extends AbstractSeed | |
{ | |
/** | |
* Run Method. | |
* | |
* Write your database seeder using this method. | |
* | |
* More information on writing seeds is available here: | |
* http://docs.phinx.org/en/latest/seeding.html | |
* | |
* @return void | |
*/ | |
public function run() | |
{ | |
$generator = \Faker\Factory::create('en_IN'); | |
$data = [ | |
'name' =>function() use ($generator) { return $generator->unique()->company .' '. $generator->companySuffix;}, | |
'contact_person' => function() use ($generator) { return $generator->name;}, | |
'address' => function() use ($generator) { return $generator->streetAddress;}, | |
'city' => function() use ($generator) { return $generator->city;}, | |
'state' => function() use ($generator) { return $generator->state;}, | |
'contact_number' => function() use ($generator) { return $generator->mobileNumber;} , | |
'other_contact_number' => function() use ($generator) { return $generator->mobileNumber;} , | |
'landline_number' => function() use ($generator) { return $generator->mobileNumber;}, | |
'created' => function() use ($generator) { return $generator->dateTimeThisYear->format('Y-m-d H:i:s');}, | |
'modified' => function() use ($generator) { return$generator->dateTimeThisYear->format('Y-m-d H:i:s');}, | |
]; | |
$populator = new Faker\ORM\CakePHP\Populator($generator); | |
$populator->addEntity('Customers', 11,$data); | |
$insertedPKs = $populator->execute(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment