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


PHP factory函数代码示例

本文整理汇总了PHP中factory函数的典型用法代码示例。如果您正苦于以下问题:PHP factory函数的具体用法?PHP factory怎么用?PHP factory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: makeBusiness

 private function makeBusiness(User $owner)
 {
     $business = factory(Business::class)->make();
     $business->save();
     $business->owners()->attach($owner);
     return $business;
 }
开发者ID:martinsv,项目名称:timegrid,代码行数:7,代码来源:AppointmentTest.php

示例2: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $dishNames = ['Chicken Parmesano', 'Salad Niçoise', 'Turkey Marco Polo', 'Tuna Marinara', 'Salmon Louis Salad', 'Chicken Kiev', 'Pasta Primavera', 'Stroganoff', 'Duck à l\'orange', 'Spaghetti Carbonara', 'Creme du Barry', 'Turkey Cordon Bleu', 'Salsa Verde', 'Mexican Burrito'];
     foreach ($dishNames as $dishName) {
         factory(App\Dish::class)->create(['user_id' => 1, 'name' => $dishName]);
     }
 }
开发者ID:ricardosncosta,项目名称:nugest-api,代码行数:12,代码来源:DishesTableSeeder.php

示例3: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     DB::table('cijfer')->truncate();
     $toetsen = Toets::all();
     //$cijfers = factory(Cijfer::class, count($toetsen)*count($leerlingen))->create();
     for ($i = 0; $i < count($toetsen); ++$i) {
         //dd($toetsen[$i]->toetsenlijst()->first()->lesopdracht()->first()->klas()->first()->leerlingen()->first());
         $klas = $toetsen[$i]->toetsenlijst()->first()->lesopdracht()->first()->klas()->first()->code;
         if (substr($klas, 0, 1) != '5') {
             continue;
         }
         $leerlingen = $toetsen[$i]->toetsenlijst()->first()->lesopdracht()->first()->klas()->first()->leerlingen()->get();
         for ($j = 0; $j < count($leerlingen); ++$j) {
             $cijfer = factory(Cijfer::class, 1)->create();
             $cijfer["waarde"] = rand(0, 10);
             $cijfer["toets_id"] = $toetsen[$i]["id"];
             $cijfer["leerling_id"] = $leerlingen[$j]["id"];
             $cijfer->save();
         }
     }
     DB::statement('SET FOREIGN_KEY_CHECKS = 1');
     Model::reguard();
 }
开发者ID:svro,项目名称:libcore,代码行数:30,代码来源:CijferSeeder.php

示例4: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     factory(App\Event::class, 1000)->create();
     factory(App\Steminar::class, 1000)->create();
     factory(App\Team::class, 100)->create();
     factory(App\User::class, 100)->create();
 }
开发者ID:NuLeaf,项目名称:nuleaf-website,代码行数:12,代码来源:DatabaseSeeder.php

示例5: setup

 public function setup()
 {
     parent::setup();
     $todo = factory(\App\Todo::class)->create();
     // echo $todo;
     $this->id = $todo['id'];
 }
开发者ID:cncgl,项目名称:laravel-todo,代码行数:7,代码来源:TodoTest.php

示例6: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     factory('App\\User', 100)->create();
     Model::reguard();
     // $this->call(UserTableSeeder::class);
 }
开发者ID:jorgenaranjo,项目名称:crudAngularLaravel,代码行数:12,代码来源:DatabaseSeeder.php

示例7: testManufacturerAdd

 public function testManufacturerAdd()
 {
     $manufacturers = factory(Manufacturer::class, 'manufacturer')->make();
     $values = ['name' => $manufacturers->name];
     Manufacturer::create($values);
     $this->tester->seeRecord('manufacturers', $values);
 }
开发者ID:dmeltzer,项目名称:snipe-it,代码行数:7,代码来源:ManufacturerTest.php

示例8: testUploadAvatar

 public function testUploadAvatar()
 {
     $user = factory(\App\User::class)->create();
     $this->actingAs($user)->visit('/dashboard');
     $this->visit('/profile');
     $this->call('POST', '/profile/update/avatar', ['avatar' => ' /images/avatar.png', '_token' => csrf_token()]);
 }
开发者ID:andela-womokoro,项目名称:learning_mgt_system,代码行数:7,代码来源:AvatarUpdateTest.php

示例9: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     for ($i = 0; $i < 100; $i++) {
         $word = factory(JapaneseWords\Word::class)->make();
         $word->save();
     }
 }
开发者ID:ikari7789,项目名称:jwords.standingmist.com,代码行数:12,代码来源:WordSeeder.php

示例10: testVideoUpload

 public function testVideoUpload()
 {
     $user = factory(\App\User::class)->create();
     $this->actingAs($user)->visit('/dashboard');
     $this->click('Upload Video');
     $this->type('Something to watch', 'title')->type('Science', 'category')->type('https://www.youtube.com/watch?v=ssuiqtreiBg', 'url')->type('Some text for the description', 'description')->press('Upload')->see('The video has been successfully uploaded.');
 }
开发者ID:andela-womokoro,项目名称:learning_mgt_system,代码行数:7,代码来源:VideoUploadTest.php

示例11: testVerificationVerify_ReturnsVerifiedResponseValidCodeProvided

 public function testVerificationVerify_ReturnsVerifiedResponseValidCodeProvided()
 {
     factory(\Legit\Code\Code::class)->create();
     $data = ['phone_number' => '27848118111', 'client_user_id' => 1, 'code' => '123456'];
     $this->post('api/v1/verification/verify', $data)->seeJsonEquals(['status' => 200, 'message' => 'This phone number is verified', 'data' => ['phone_number' => '27848118111', 'client_user_id' => 1]]);
     $this->assertResponseStatus(200);
 }
开发者ID:etiennemarais,项目名称:legit,代码行数:7,代码来源:VerificationTest.php

示例12: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // apagar todos os registro da tabela
     //\CodeProject\Entities\ProjectMember::truncate();
     // criar 10 registros na tabela
     factory(\CodeProject\Entities\ProjectMember::class, 10)->create();
 }
开发者ID:estevesklein,项目名称:CodeProject-curso-laravel,代码行数:12,代码来源:ProjectMemberTableSeeder.php

示例13: run

 public function run()
 {
     // refresh migration
     Artisan::call('migrate:refresh');
     // init data
     // create user
     $user = factory(App\User::class)->create();
     // create categories
     $categories = factory(App\Category::class, 5)->create(['user_id' => $user->id]);
     // create tags
     $tags = factory(App\Tag::class, 10)->create(['user_id' => $user->id]);
     // create articles
     factory(App\Article::class, 20)->create(['user_id' => $user->id, 'category_id' => $categories->random()->id])->each(function ($article) use($tags) {
         $tagids = [];
         $tags->random(rand(2, 10))->each(function ($tag) use(&$tagids) {
             array_push($tagids, $tag->id);
         });
         $article->tags()->attach($tagids);
     });
     // create knots
     factory(App\Knot::class, 10)->create(['user_id' => $user->id])->each(function ($knot) use($tags) {
         $tagids = [];
         $tags->random(rand(2, 10))->each(function ($tag) use(&$tagids) {
             array_push($tagids, $tag->id);
         });
         $knot->tags()->attach($tagids);
     });
 }
开发者ID:angelWendy,项目名称:streamlet,代码行数:28,代码来源:FakerDataSeeder.php

示例14: testIndexUri

 /**
  *
  */
 public function testIndexUri()
 {
     $user = factory(App\User::class)->create();
     $route = $this->actingAs($user);
     $route->visit('/points');
     $route->seeStatusCode(200);
 }
开发者ID:Tjoosten,项目名称:refugee,代码行数:10,代码来源:CollectionPointsTest.php

示例15: testShow

 public function testShow()
 {
     $project = factory(Project::class)->create();
     $this->action('GET', 'ProjectsController@show', $project);
     $this->assertResponseOk();
     $this->assertViewHas('project');
 }
开发者ID:nav2855,项目名称:neontsunami,代码行数:7,代码来源:ProjectsControllerTest.php


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