1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- /*
- |--------------------------------------------------------------------------
- | Model Factories
- |--------------------------------------------------------------------------
- |
- | Here you may define all of your model factories. Model factories give
- | you a convenient way to create models for testing and seeding your
- | database. Just tell the factory how a default model should look.
- |
- | "A blueprint for an Eloquent model".
- |
- */
- /** @var \Illuminate\Database\Eloquent\Factory $factory */
- use App\Post;
- use App\User;
- use Faker\Generator;
- $factory->define(User::class, function (Generator $faker) {
- static $password;
- return [
- 'name' => $faker->name,
- 'email' => $faker->unique()->safeEmail,
- 'password' => $password ?: $password = bcrypt('secret'),
- 'remember_token' => str_random(10),
- ];
- });
- $factory->define(Post::class, function (Generator $faker) {
- return [
- 'user_id' => function () {
- return factory(User::class)->create()->id;
- },
- 'title' => $faker->sentence,
- 'body' => $faker->paragraph,
- ];
- });
|