/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Character::findOrFail(1)->guilds()->attach(Guild::findOrFail(1));
     $guilds = Guild::all();
     $users = User::with('characters')->get();
     foreach ($users as $i => $user) {
         if ($i == 0) {
             continue;
         }
         $user->characters->random()->guilds()->attach($guilds->random());
     }
 }
Esempio n. 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $guilds = Guild::all();
     foreach ($guilds as $guild) {
         factory(Event::class, mt_rand(1, 3))->create(['guild_id' => $guild->id]);
         $events = Event::where('guild_id', $guild->id)->get();
         foreach ($events as $event) {
             $day = Carbon::now()->startOfMonth();
             $day->setTime(20, 0, 0);
             $day->addDays(mt_rand(0, 6));
             $end = $day->copy()->endOfMonth();
             do {
                 factory(EventOccurrence::class)->create(['event_id' => $event->id, 'begin_at' => $day, 'end_at' => $day->copy()->addHours(2)]);
                 $day->addWeek();
             } while ($day->lte($end));
         }
     }
 }