Files
ticketbeast/database/factories/ModelFactory.php
2016-11-09 10:35:36 -05:00

54 lines
1.5 KiB
PHP

<?php
use Carbon\Carbon;
/*
|--------------------------------------------------------------------------
| 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.
|
*/
/** @var \Illuminate\Database\Eloquent\Factory $factory */
$factory->define(App\User::class, function (Faker\Generator $faker) {
static $password;
return [
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
'password' => $password ?: $password = bcrypt('secret'),
'remember_token' => str_random(10),
];
});
$factory->define(App\Concert::class, function (Faker\Generator $faker) {
return [
'title' => 'Example Band',
'subtitle' => 'with The Fake Openers',
'date' => Carbon::parse('+2 weeks'),
'ticket_price' => 2000,
'venue' => 'The Example Theatre',
'venue_address' => '123 Example Lane',
'city' => 'Fakeville',
'state' => 'ON',
'zip' => '90210',
'additional_information' => 'Some sample additional information.',
];
});
$factory->state(App\Concert::class, 'published', function ($faker) {
return [
'published_at' => Carbon::parse('-1 week'),
];
});
$factory->state(App\Concert::class, 'unpublished', function ($faker) {
return [
'published_at' => null,
];
});