當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Factory::Create方法代碼示例

本文整理匯總了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));
     }
 }
開發者ID:rafael31194,項目名稱:SiGesAdmin,代碼行數:7,代碼來源:ArticleTableSeeder.php

示例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)]);
 }
開發者ID:skinuxgeek,項目名稱:NewsWise,代碼行數:12,代碼來源:WritersTableSeeder.php

示例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)]);
     }
 }
開發者ID:khaled-barca,項目名稱:MyTunnelVision,代碼行數:30,代碼來源:TableSeeder.php

示例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)]);
 }
開發者ID:kristofsw,項目名稱:landoretti-webdev,代碼行數:14,代碼來源:UserSeeder.php

示例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);
 }
開發者ID:nilove,項目名稱:motibubackend,代碼行數:10,代碼來源:IndustriesTableSeeder.php

示例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));
     }
 }
開發者ID:rafael31194,項目名稱:SiGesAdmin,代碼行數:15,代碼來源:UserTableSeeder.php

示例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]);
     }
 }
開發者ID:kristofsw,項目名稱:landoretti-webdev,代碼行數:21,代碼來源:AuctionSeeder.php


注:本文中的Faker\Factory::Create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。