当前位置: 首页>>代码示例>>PHP>>正文


PHP Factory::create方法代码示例

本文整理汇总了PHP中Faker\Factory::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::create方法的具体用法?PHP Factory::create怎么用?PHP Factory::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Faker\Factory的用法示例。


在下文中一共展示了Factory::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 50) as $index) {
         User::create(['username' => $faker->word . $index, 'email' => $faker->email, 'password' => 'secret']);
     }
 }
开发者ID:itsSkyler,项目名称:larabook,代码行数:7,代码来源:UsersTableSeeder.php

示例2: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Product::create(['product_name' => $faker->word, 'details' => $faker->paragraph, 'picture' => 'uploads/products/1default.jpg', 'min_price' => $faker->randomDigit, 'max_price' => $faker->randomDigitNotNull, 'crop_id' => 1, 'location' => $faker->country, 'expiry_date' => $faker->date('Y--m-d')]);
     }
 }
开发者ID:talha08,项目名称:Farmer-Bazar,代码行数:7,代码来源:ProductsTableSeeder.php

示例3: run

 public function run()
 {
     $faker = Factory::create();
     foreach (range(1, 10) as $index) {
         Category::create(['name' => $faker->firstName, 'description' => $faker->text(130), 'active' => $faker->boolean(85)]);
     }
 }
开发者ID:Tisho84,项目名称:laravel-work,代码行数:7,代码来源:CategoriesTableSeeder.php

示例4: load

 public function load(ObjectManager $manager)
 {
     $faker = Factory::create();
     for ($i = 0; $i < 50; $i++) {
         static $id = 1;
         $post = new Post();
         $post->setTitle($faker->sentence);
         $post->setAuthorEmail('user_admin@blog.com');
         $post->setImageName("images/post/foto{$id}.jpg");
         $post->setContent($faker->realText($maxNbChars = 5000, $indexSize = 2));
         $marks = array();
         for ($q = 0; $q < rand(1, 10); $q++) {
             $marks[] = rand(1, 5);
         }
         $post->setMarks($marks);
         $post->addMark(5);
         $manager->persist($post);
         $this->addReference("{$id}", $post);
         $id = $id + 1;
         $rand = rand(3, 7);
         for ($j = 0; $j < $rand; $j++) {
             $comment = new Comment();
             $comment->setAuthorEmail('user_user@blog.com');
             $comment->setCreatedBy('user_user');
             $comment->setContent($faker->realText($maxNbChars = 500, $indexSize = 2));
             $comment->setPost($post);
             $post->getComments()->add($comment);
             $manager->persist($comment);
             $manager->flush();
         }
     }
     $manager->flush();
 }
开发者ID:syrotchukandrew,项目名称:blog,代码行数:33,代码来源:LoadPostData.php

示例5: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     // Validate form
     $this->validate($request, ['user_quantity' => 'required|integer|between:1,100']);
     // Assign variables
     $form_array = $request->input('form_array', array());
     $user_quantity = $request->input('user_quantity');
     // Generate Fake User Data
     $faker = Factory::create('en_US');
     $payload = array();
     $deposit_address = in_array('address', $form_array);
     $deposit_phone = in_array('phone', $form_array);
     $deposit_birthdate = in_array('birthdate', $form_array);
     for ($i = 0; $i < $user_quantity; $i++) {
         $individual = array();
         $individual[] = $faker->name;
         if ($deposit_address) {
             $individual[] = $faker->address;
         }
         if ($deposit_phone) {
             $individual[] = $faker->phoneNumber;
         }
         if ($deposit_birthdate) {
             $individual[] = $faker->date($format = 'Y-m-d', $max = 'now');
         }
         // Append to payload array
         $payload[] = $individual;
     }
     // Push data to view and return view
     return view('results', ['payload' => $payload, 'source' => 'fake-user', 'title' => 'Fake User Generator']);
 }
开发者ID:sietekk,项目名称:cscie15.project3,代码行数:37,代码来源:FakeUserController.php

示例6: run

 public function run()
 {
     $faker = Faker::create();
     for ($i = 0; $i < 50; $i++) {
         \DB::table('states')->insert(array('state' => $faker->unique()->state, 'code' => $faker->postcode));
     }
 }
开发者ID:CarlosKun,项目名称:solyluna,代码行数:7,代码来源:CountriesTableSeeder.php

示例7: setUp

 protected function setUp()
 {
     if (!static::$staticConnection) {
         static::$staticConnection = new Connection($this->server, $this->dbName);
     }
     $this->connection = static::$staticConnection;
     if (!static::$staticFaker) {
         static::$staticFaker = Factory::create();
     }
     if (!static::$staticMongator) {
         static::$staticMongator = new Mongator(new $this->metadataFactoryClass());
         static::$staticMongator->setConnection('default', $this->connection);
         static::$staticMongator->setDefaultConnectionName('default');
     }
     if (!static::$staticConfigClasses) {
         static::$staticConfigClasses = (require __DIR__ . '/../../configClasses.php');
     }
     $this->faker = static::$staticFaker;
     $this->mongator = static::$staticMongator;
     $this->unitOfWork = $this->mongator->getUnitOfWork();
     $this->metadataFactory = $this->mongator->getMetadataFactory();
     $this->cache = $this->mongator->getFieldsCache();
     foreach ($this->mongator->getAllRepositories() as $repository) {
         $repository->getIdentityMap()->clear();
     }
     $this->mongo = $this->connection->getMongo();
     $this->db = $this->connection->getMongoDB();
     foreach ($this->db->listCollections() as $collection) {
         //  $collection->drop();
     }
 }
开发者ID:mongator,项目名称:factory,代码行数:31,代码来源:TestCase.php

示例8: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     //
     $this->app->singleton(FakerGenerator::class, function () {
         return Factory::create('zh_CN');
     });
 }
开发者ID:rossli,项目名称:hai30,代码行数:12,代码来源:AppServiceProvider.php

示例9: postGenerate

 /**
  * Responds to requests to POST /lorem
  */
 public function postGenerate(Request $request)
 {
     // Validate the request data
     // num_users - how many users should be created
     // tb_word_count - how many words in password
     $this->validate($request, ['num_users' => 'required|integer|min:1|max:99', 'tb_word_count' => 'integer|min:1|max:9']);
     $num_users = $request->input('num_users');
     $lang = $request->input('lang');
     $address1 = $request->input('address1');
     $profile = $request->input('profile');
     $tb_word_count = $request->input('tb_word_count');
     $cb_number = $request->input('cb_number');
     $cb_symbol = $request->input('cb_symbol');
     $pwd_case = $request->input('pwd_case');
     //The section below declares the arrays needed to hold random user data
     //and then populates those arrays.
     //instantiate new PwdGenerator object
     $a = new \App\PwdGenerator($tb_word_count, $pwd_case, $cb_number, $cb_symbol);
     $pwd_array = [];
     $faker = \Faker\Factory::create($lang);
     $name_array = [];
     $address_array = [];
     $profile_array = [];
     for ($i = 0; $i < $num_users; $i++) {
         // populate array with random names
         $name_array[$i] = $faker->name;
         //populate array with random address info
         $address_array[$i] = $faker->address;
         //populate array with random profile text
         $profile_array[$i] = $faker->text;
         //populate array with random passwords
         $pwd_array[$i] = $a->generatePwd();
     }
     return view('random.generate')->with('num_users', $num_users)->with('lang', $lang)->with('address1', $address1)->with('profile', $profile)->with('tb_word_count', $tb_word_count)->with('cb_number', $cb_number)->with('cb_symbol', $cb_symbol)->with('pwd_case', $pwd_case)->with('name_array', $name_array)->with('address_array', $address_array)->with('profile_array', $profile_array)->with('pwd_array', $pwd_array);
 }
开发者ID:anthon94,项目名称:p3,代码行数:38,代码来源:RandomController.php

示例10: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     for ($i = 0; $i < 40; $i++) {
         \DB::table('usuarios')->insert(array('snombre' => $faker->firstname, 'sapellido' => $faker->lastname, 'scontrasena' => \Hash::make('12345'), 'scorreo' => $faker->unique()->email, 'badministra' => 0));
     }
 }
开发者ID:matc04,项目名称:Laravel,代码行数:12,代码来源:UsuarioSeed.php

示例11: testPostItem

 public function testPostItem()
 {
     $client = static::createClient();
     $faker = Factory::create();
     $client->request('POST', '/api/items', array('name' => $faker->name, 'description' => $faker->text));
     $this->assertEquals(201, $client->getResponse()->getStatusCode());
 }
开发者ID:nanofelis,项目名称:sf2-api-rest-demo,代码行数:7,代码来源:ItemsControllerTest.php

示例12: setUp

 public function setUp()
 {
     date_default_timezone_set('Europe/Berlin');
     $faker = Factory::create();
     $this->veryLongString = preg_replace("/[^A-Za-z0-9]/", '', $faker->sentence(90));
     $this->faker = $faker;
 }
开发者ID:vmrose,项目名称:clientlibrary,代码行数:7,代码来源:CompanyMemberTest.php

示例13: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Inventory::create([]);
     }
 }
开发者ID:jonagoldman,项目名称:channelmanager,代码行数:7,代码来源:InventoriesTableSeeder.php

示例14: run

 public function run()
 {
     $faker = Faker::create('pt_BR');
     foreach (range(1, 10) as $index) {
         Pedido::create(['cliente_id' => rand(1, 2), 'fornecedor_id' => rand(1, 2), 'entrega_endereco' => $faker->text(), 'entrega_data' => $faker->date('Y-m-d'), 'frete' => $faker->text(), 'pgto' => $faker->text(), 'total' => rand(3, 3), 'obs' => $faker->text()]);
     }
 }
开发者ID:waldenylson,项目名称:alfredapp,代码行数:7,代码来源:PedidosTableSeeder.php

示例15: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('tbl_users')->truncate();
     $faker = \Faker\Factory::create();
     for ($i = 0; $i < 10; $i++) {
         switch (mt_rand(1, 4)) {
             case 1:
                 $insertion = 'van';
                 break;
             case 2:
                 $insertion = 'de';
                 break;
             case 3:
                 $insertion = 'van der';
                 break;
             default:
                 $insertion = '';
         }
         $city2 = "";
         $street2 = "";
         $house_nr2 = "";
         $postalcode2 = "";
         if (mt_rand(1, 2) == 1) {
             $street2 = $faker->streetName;
             $house_nr2 = $faker->numberBetween(0, 2000);
             $postalcode2 = $faker->postcode;
             $city2 = $faker->city;
         }
         \App\User::create(['username' => $faker->userName, 'password' => password_hash('password', PASSWORD_DEFAULT), 'email' => $faker->email, 'firstname' => $faker->firstName, 'lastname' => $faker->lastName, 'insertion' => $insertion, 'phone_nr' => $faker->phoneNumber, 'birthdate' => $faker->date($format = 'Y-m-d', $max = 'now') . " " . $faker->time($format = 'H:i:s', $max = 'now'), 'city' => $faker->city, 'street' => $faker->streetName, 'house_nr' => $faker->numberBetween(0, 2000), 'postalcode' => $faker->postcode, 'city2' => $city2, 'street2' => $street2, 'house_nr2' => $house_nr2, 'postalcode2' => $postalcode2]);
     }
 }
开发者ID:justmemaarten,项目名称:vlambeer,代码行数:36,代码来源:UsersTableSeeder.php


注:本文中的Faker\Factory::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。