本文整理汇总了PHP中Faker\Factory::Create方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::Create方法的具体用法?PHP Factory::Create怎么用?PHP Factory::Create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Faker\Factory
的用法示例。
在下文中一共展示了Factory::Create方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$faker = Faker::Create();
for ($i = 0; $i <= 2; $i++) {
\DB::table('articles')->insert(array('title' => $faker->realText($maxNbChars = 10, $indexSize = 2), 'body' => $faker->paragraph(rand(2, 5)), 'published_at' => $faker->dateTimeBetween('-2 years', '-0 years')->format('Y-m-d'), 'user_id' => $i + 1));
}
}
示例2: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker::Create();
$name = $faker->name;
Eloquent::unguard();
Writers::create(['name' => $name, 'bio' => 'This is just a sample Writer. There is nothing to say here!', 'image' => '/images/writers/SampleWriter.jpg', 'slug' => str_replace(' ', '-', $name)]);
}
示例3: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker::Create();
foreach (range(1, 10) as $seededItem) {
User::create(['first_name' => $faker->name, 'last_name' => $faker->name, 'password' => Hash::make('123456'), 'type' => false, 'sex' => $faker->boolean(), 'email' => $faker->email, 'date_of_birth' => $faker->date('Y-m-d')]);
}
$users = User::all()->lists('id')->toArray();
foreach (range(1, 100) as $seededItem) {
Post::create(['user_id' => $faker->randomElement($users), 'body' => $faker->text, 'vote_count' => 0]);
}
$posts = Post::all()->lists('id')->toArray();
Comment::create(['user_id' => $faker->randomElement($users), 'body' => $faker->text, 'vote_count' => 0, 'parent_id' => null]);
foreach (range(1, 100) as $seededItem) {
Post_Vote::create(['user_id' => $faker->randomElement($users), 'post_id' => $faker->randomElement($posts), 'up' => $faker->boolean()]);
Comment::create(['user_id' => $faker->randomElement($users), 'parent_id' => $faker->randomElement(Comment::all()->lists('id')->toArray()), 'post_id' => $faker->randomElement($posts), 'body' => $faker->text, 'vote_count' => 0]);
Tag::create(['name' => $faker->text, 'private' => $faker->boolean()]);
}
$comments = Comment::all()->lists('id')->toArray();
$tags = Tag::all()->lists('id')->toArray();
foreach (range(1, 100) as $seededItem) {
Comment_Vote::create(['user_id' => $faker->randomElement($users), 'comment_id' => $faker->randomElement($comments), 'up' => $faker->boolean()]);
Tag_User::create(['user_id' => $faker->randomElement($users), 'tag_id' => $faker->randomElement($tags)]);
Post_Tag::create(['tag_id' => $faker->randomElement($tags), 'post_id' => $faker->randomElement($posts)]);
}
}
示例4: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker::Create();
foreach (range(1, 10) as $index) {
DB::table('users')->insert(['company' => $faker->company, 'email' => $faker->email, 'password' => bcrypt('secret'), 'country' => $faker->country, 'zipcode' => $faker->postcode, 'city' => $faker->city, 'address' => $faker->streetAddress, 'phone' => '+32 ' . $faker->randomNumber(2) . ' ' . $faker->randomNumber(3) . ' ' . $faker->randomNumber(2) . ' ' . $faker->randomNumber(2), 'accnumber' => $faker->randomNumber(2) . ' ' . $faker->randomNumber(3) . ' ' . $faker->randomNumber(2) . ' ' . $faker->randomNumber(2), 'vatnumber' => $faker->randomNumber(2) . ' ' . $faker->randomNumber(3) . ' ' . $faker->randomNumber(2) . ' ' . $faker->randomNumber(2)]);
}
DB::table('users')->insert(['company' => 'Kristof Sweerts', 'email' => 'kristof.sweerts@gmail.com', 'password' => bcrypt('secret'), 'country' => 'Belgium', 'zipcode' => '2850', 'city' => 'Boom', 'address' => 'Gevaertlaan 71', 'phone' => '+32 ' . $faker->randomNumber(2) . ' ' . $faker->randomNumber(3) . ' ' . $faker->randomNumber(2) . ' ' . $faker->randomNumber(2), 'accnumber' => $faker->randomNumber(2) . ' ' . $faker->randomNumber(3) . ' ' . $faker->randomNumber(2) . ' ' . $faker->randomNumber(2), 'vatnumber' => $faker->randomNumber(2) . ' ' . $faker->randomNumber(3) . ' ' . $faker->randomNumber(2) . ' ' . $faker->randomNumber(2)]);
DB::table('users')->insert(['company' => 'Kristof Sweerts School', 'email' => 'kristof.sweerts@student.kdg.be', 'password' => bcrypt('secret'), 'country' => 'Belgium', 'zipcode' => '2850', 'city' => 'Boom', 'address' => 'Gevaertlaan 71', 'phone' => '+32 ' . $faker->randomNumber(2) . ' ' . $faker->randomNumber(3) . ' ' . $faker->randomNumber(2) . ' ' . $faker->randomNumber(2), 'accnumber' => $faker->randomNumber(2) . ' ' . $faker->randomNumber(3) . ' ' . $faker->randomNumber(2) . ' ' . $faker->randomNumber(2), 'vatnumber' => $faker->randomNumber(2) . ' ' . $faker->randomNumber(3) . ' ' . $faker->randomNumber(2) . ' ' . $faker->randomNumber(2)]);
}
示例5: run
public function run()
{
$faker = Faker::Create();
$industriesImports = explode("\n", \File::get('app/dox/industries.txt'));
$industries = [];
foreach ($industriesImports as $industry) {
$industries[] = ['name' => $industry];
}
Industry::insert($industries);
}
示例6: run
public function run()
{
$faker = Faker::Create();
for ($i = 0; $i <= 29; $i++) {
$firstName = $faker->firstName;
$lastName = $faker->lastName;
$randon = rand(1, 2);
if ($randon == 1) {
$id = \DB::table('users')->insertGetId(array('first_name' => $firstName, 'last_name' => $lastName, 'user_name' => "{$firstName}{$lastName}", 'email' => $faker->unique()->email, 'password' => \Hash::make('1234'), 'rol' => 'secretaria'));
} else {
$id = \DB::table('users')->insertGetId(array('first_name' => $firstName, 'last_name' => $lastName, 'user_name' => "{$firstName}{$lastName}", 'email' => $faker->unique()->email, 'password' => \Hash::make('1234'), 'rol' => 'docente'));
}
\DB::table('user_profiles')->insert(array('user_id' => $id, 'bio' => $faker->paragraph(rand(2, 5)), 'birthday' => $faker->dateTimeBetween('-45 years', '-15 years')->format('Y-m-d'), 'website' => 'http://www.' . $faker->domainName, 'twitter' => 'http://www.twiter.com/' . $faker->userName));
}
}
示例7: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker::Create();
foreach (range(1, 5) as $index) {
DB::table('auctions')->insert(['user_id' => '11', 'style' => 'Minimalism', 'title' => $faker->firstNameMale, 'author' => $faker->name, 'year' => '1988', 'width' => '50', 'height' => '50', 'depth' => '', 'description' => $faker->catchPhrase, 'condition' => $faker->catchPhrase, 'origin' => $faker->catchPhrase, 'img_artwork' => 'uwot.jpg', 'img_signature' => 'uwot.jpg', 'img_optional' => '', 'minprice' => '10000', 'maxprice' => '20000', 'estprice' => '15000', 'highest_bid' => '0', 'buyoutprice' => '20000', 'bid_amount' => 0, 'enddate' => '02-05-2016', 'pending' => false, 'refused' => false, 'active' => true, 'expired' => false, 'sold' => false]);
}
foreach (range(1, 5) as $index) {
DB::table('auctions')->insert(['user_id' => $index, 'style' => 'Minimalism', 'title' => $faker->firstNameMale, 'author' => $faker->name, 'year' => '1988', 'width' => '50', 'height' => '50', 'depth' => '', 'description' => $faker->catchPhrase, 'condition' => $faker->catchPhrase, 'origin' => $faker->catchPhrase, 'img_artwork' => 'uwot.jpg', 'img_signature' => 'uwot.jpg', 'img_optional' => '', 'minprice' => '5000', 'maxprice' => '10000', 'highest_bid' => '0', 'estprice' => '7500', 'buyoutprice' => '20000', 'bid_amount' => 0, 'enddate' => '19-01-2016', 'pending' => false, 'refused' => false, 'active' => true, 'expired' => false, 'sold' => false]);
}
DB::table('auctions')->insert(['user_id' => '6', 'style' => 'Minimalism', 'title' => $faker->firstNameMale, 'author' => $faker->name, 'year' => '1988', 'width' => '50', 'height' => '50', 'depth' => '', 'description' => $faker->catchPhrase, 'condition' => $faker->catchPhrase, 'origin' => $faker->catchPhrase, 'img_artwork' => 'uwot.jpg', 'img_signature' => 'uwot.jpg', 'img_optional' => '', 'minprice' => '6000', 'maxprice' => '12000', 'estprice' => '8000', 'highest_bid' => '10000', 'bid_amount' => 2, 'buyoutprice' => '20000', 'enddate' => '24-01-2016', 'pending' => false, 'refused' => false, 'active' => true, 'expired' => false, 'sold' => false]);
DB::table('auctions')->insert(['user_id' => '11', 'style' => 'Minimalism', 'title' => $faker->firstNameMale, 'author' => $faker->name, 'year' => '1988', 'width' => '50', 'height' => '50', 'depth' => '', 'description' => $faker->catchPhrase, 'condition' => $faker->catchPhrase, 'origin' => $faker->catchPhrase, 'img_artwork' => 'uwot.jpg', 'img_signature' => 'uwot.jpg', 'img_optional' => '', 'minprice' => '5000', 'maxprice' => '10000', 'estprice' => '7500', 'buyoutprice' => '20000', 'highest_bid' => '5600', 'bid_amount' => 1, 'enddate' => '02-05-2016', 'pending' => false, 'refused' => false, 'active' => true, 'expired' => false, 'sold' => false]);
DB::table('auctions')->insert(['user_id' => '8', 'style' => 'Minimalism', 'title' => $faker->firstNameMale, 'author' => $faker->name, 'year' => '1988', 'width' => '50', 'height' => '50', 'depth' => '', 'description' => $faker->catchPhrase, 'condition' => $faker->catchPhrase, 'origin' => $faker->catchPhrase, 'img_artwork' => 'uwot.jpg', 'img_signature' => 'uwot.jpg', 'img_optional' => '', 'minprice' => '5000', 'maxprice' => '10000', 'estprice' => '7500', 'buyoutprice' => '20000', 'highest_bid' => '0', 'bid_amount' => 0, 'enddate' => '02-05-2016', 'pending' => false, 'refused' => false, 'active' => false, 'expired' => true, 'sold' => false]);
foreach (range(1, 5) as $index) {
DB::table('auctions')->insert(['user_id' => $index, 'style' => 'Minimalism', 'title' => $faker->firstNameMale, 'author' => $faker->name, 'year' => '1988', 'width' => '50', 'height' => '50', 'depth' => '', 'description' => $faker->catchPhrase, 'condition' => $faker->catchPhrase, 'origin' => $faker->catchPhrase, 'img_artwork' => 'uwot.jpg', 'img_signature' => 'uwot.jpg', 'img_optional' => '', 'minprice' => '5000', 'maxprice' => '10000', 'highest_bid' => '0', 'estprice' => '7500', 'buyoutprice' => '20000', 'bid_amount' => 0, 'enddate' => '19-01-2016', 'pending' => false, 'refused' => false, 'active' => false, 'expired' => false, 'sold' => true]);
}
}