/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); factory(App\Piece::class, 24)->create(); $katy = App\Studio::create(['slug' => 'katy', 'email' => '*****@*****.**', 'phone' => '123-123-1234', 'address' => '829 S Mason Rd #260', 'city' => 'Katy', 'stateCode' => 'TX', 'postCode' => '77450', 'lat' => '29.7704014', 'lng' => '-95.7500742']); $dunedin = App\Studio::create(['slug' => 'dunedin', 'email' => '*****@*****.**', 'phone' => '123-123-1234', 'address' => '2033 Yale Ave', 'city' => 'Dunedin', 'stateCode' => 'FL', 'postCode' => '34698', 'lat' => '28.039364', 'lng' => '-82.779006']); factory(App\Event::class, rand(12, 40))->make()->each(function ($event) use($katy) { $katy->events()->save($event); }); factory(App\Event::class, rand(12, 40))->make()->each(function ($event) use($dunedin) { $dunedin->events()->save($event); }); // factory(App\Studio::class, 3)->create()->each(function($studio) { // factory(App\Event::class, rand(12, 40))->make()->each(function ($event) use ($studio) { // $studio->events()->save($event); // }); // }); App\User::create(['name' => 'Steve', 'email' => '*****@*****.**', 'password' => Hash::make('secret')]); factory(App\User::class, 5)->create(); $this->call(RolePermSeeder::class); Model::reguard(); }
$factory->define(App\User::class, function (Faker\Generator $faker) { return ['name' => $faker->name, 'email' => $faker->email, 'password' => bcrypt(str_random(10)), 'remember_token' => str_random(10)]; }); $factory->define(App\Piece::class, function (Faker\Generator $faker) { $title = str_replace('.', '', $faker->text(24)); $slug = str_slug($title); return ['title' => $title, 'slug' => $slug, 'description' => $faker->paragraph]; }); $factory->define(App\Event::class, function (Faker\Generator $faker) { $rand = rand(5, 60); $startHr = rand(10, 19); $starts = \Carbon\Carbon::now()->addDays($rand)->hour($startHr)->minute(0)->second(0); $ends = \Carbon\Carbon::now()->addDays($rand)->hour($startHr + rand(2, 4))->minute(0)->second(0); return ['title' => $faker->text(18), 'lead' => $faker->sentence, 'description' => $faker->paragraph, 'price' => 35.0, 'seats' => 30, 'starts' => $starts, 'ends' => $ends, 'studio_id' => App\Studio::first()->id, 'artist' => !rand(0, 3) ? $faker->name : '']; }); $factory->define(App\Category::class, function (Faker\Generator $faker) { return ['name' => ucwords($faker->word)]; }); $factory->define(App\Order::class, function (Faker\Generator $faker) { $subtotal = rand(25, 75); $tax_amount = 0.75 * $subtotal; $total = $subtotal + $tax_amount; return ['customer' => $faker->name, 'transaction_id' => rand(0, 1) ? $faker->md5 : '', 'payment_method' => rand(0, 1) ? 'stripe' : 'manual', 'subtotal' => $subtotal, 'tax_amount' => $tax_amount, 'total' => $total]; }); $factory->define(App\Ticket::class, function (Faker\Generator $faker) { $event = App\Event::first(); return ['event_id' => $event->id, 'order_id' => factory('App\\Order')->create()->id, 'price' => $event->price, 'checked_in' => rand(0, 5) ? false : true]; }); $factory->define(App\PartyRequest::class, function (Faker\Generator $faker) { return ['studio_id' => App\Studio::first()->id, 'piece_id' => App\Piece::first()->id, 'name' => $faker->name, 'email' => $faker->email, 'phone' => $faker->phoneNumber, 'date' => \Carbon\Carbon::now()->addMonths(rand(1, 4)), 'time' => '18:00', 'duration' => rand(0, 1) ? 2 : 3, 'type' => 'Birthday Party', 'private' => rand(0, 4) ? true : false, 'comments' => rand(0, 4) ? $faker->paragraph : '']; });