Skip to content

Commit 5630bf1

Browse files
committed
Update README.md
1 parent 4b08e2c commit 5630bf1

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff 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
1111
Schema::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
});

0 commit comments

Comments
 (0)