Exemplo n.º 1
0
 public function run()
 {
     Eloquent::unguard();
     $rounds = array();
     $tournament = Tournament::orderBy('id', 'ASC')->first();
     $players = $tournament->players()->count();
     $rt = 1;
     while ($players != 1) {
         $rounds[] = array('tournament' => $tournament->id, 'number' => $rt);
         $players /= 2;
         $rt++;
     }
     $tournament = Tournament::orderBy('id', 'DESC')->first();
     $players = $tournament->players()->count();
     $rt = 1;
     while ($players != 1) {
         $rounds[] = array('tournament' => $tournament->id, 'number' => $rt);
         $players /= 2;
         $rt++;
     }
     DB::table('rounds')->truncate();
     DB::table('rounds')->insert($rounds);
     DB::table('rounds')->insert(array(array('tournament' => $tournament->id, 'number' => '3')));
 }
 public function listing()
 {
     $tournaments = Tournament::orderBy("created_at", "DESC")->paginate();
     $this->display('tournaments.table', ['tournaments' => $tournaments]);
 }