File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -6,17 +6,25 @@ This package helps you generate model factories from your existing models / data
66
77### Example output
88
9- #### Migration
9+ #### Migration and Model
1010``` php
1111Schema::create('users', function (Blueprint $table) {
1212 $table->increments('id');
1313 $table->string('name');
1414 $table->string('username');
1515 $table->string('email')->unique();
1616 $table->string('password', 60);
17+ $table->integer('company_id');
1718 $table->rememberToken();
1819 $table->timestamps();
1920});
21+
22+ class User extends Model {
23+ public function company()
24+ {
25+ return $this->belongsTo(Company::class);
26+ }
27+ }
2028```
2129
2230#### Factory Result
@@ -28,6 +36,7 @@ $factory->define(App\User::class, function (Faker\Generator $faker) {
2836 'username' => $faker->userName ,
2937 'email' => $faker->safeEmail ,
3038 'password' => bcrypt($faker->password) ,
39+ 'company_id' => factory(App\Company::class)->create()->id ,
3140 'remember_token' => str_random(10) ,
3241 ];
3342});
You can’t perform that action at this time.
0 commit comments