本文整理汇总了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;
}
示例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]);
}
}
示例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();
}
示例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();
}
示例5: setup
public function setup()
{
parent::setup();
$todo = factory(\App\Todo::class)->create();
// echo $todo;
$this->id = $todo['id'];
}
示例6: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
factory('App\\User', 100)->create();
Model::reguard();
// $this->call(UserTableSeeder::class);
}
示例7: testManufacturerAdd
public function testManufacturerAdd()
{
$manufacturers = factory(Manufacturer::class, 'manufacturer')->make();
$values = ['name' => $manufacturers->name];
Manufacturer::create($values);
$this->tester->seeRecord('manufacturers', $values);
}
示例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()]);
}
示例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();
}
}
示例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.');
}
示例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);
}
示例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();
}
示例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);
});
}
示例14: testIndexUri
/**
*
*/
public function testIndexUri()
{
$user = factory(App\User::class)->create();
$route = $this->actingAs($user);
$route->visit('/points');
$route->seeStatusCode(200);
}
示例15: testShow
public function testShow()
{
$project = factory(Project::class)->create();
$this->action('GET', 'ProjectsController@show', $project);
$this->assertResponseOk();
$this->assertViewHas('project');
}