public function create($request)
 {
     $game = new Game();
     $game->name = $request->name;
     $game->short_name = $request->short_name;
     $game->logo = "https://placeholdit.imgix.net/~text?txtsize=47&txt=500%C3%97500&w=500&h=500";
     $game->save();
     return $game;
 }
Beispiel #2
0
 /**
  *儲存資料
  */
 public function store(Request $request)
 {
     $input = $request->all();
     $game = new Game();
     //game 是model 名稱
     $game->title = $input['title'];
     $game->content = $input['content'];
     $game->save();
     Game::create(['title' => $input['title']], ['content' => $input['content']]);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $_games = [['name' => 'Halo 5', 'short_name' => 'H5', 'logo' => 'img/game_logos/halo_5.png'], ['name' => 'Halo 4', 'short_name' => 'H4', 'logo' => 'img/game_logos/halo_4.png'], ['name' => 'Halo 3', 'short_name' => 'H3', 'logo' => 'img/game_logos/halo_3.png'], ['name' => 'Halo 2', 'short_name' => 'H2', 'logo' => 'img/game_logos/halo_2.png'], ['name' => 'Halo CE', 'short_name' => 'HCE', 'logo' => 'img/game_logos/halo_ce.png'], ['name' => 'Halo 3: ODST', 'short_name' => 'H3:ODST', 'logo' => 'img/game_logos/halo_odst.png'], ['name' => 'Halo Reach', 'short_name' => 'HR', 'logo' => 'img/game_logos/halo_reach.png']];
     foreach ($_games as $game) {
         $g = new Game();
         $g->name = $game['name'];
         $g->short_name = $game['short_name'];
         $g->logo = $game['logo'];
         $g->save();
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $game = new Game();
     $game->score = $request->score;
     $series = Series::find($request->series);
     if (!$series) {
         $series = new Series();
         $series->save();
     }
     $game->series_id = $series->id;
     $game->save();
     return Redirect::route('games.index')->with('message', 'Game added');
 }
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     $games = Game::all()->take(20);
     $NewGames = Game::all()->reverse()->take(5);
     $FeatGames = Game::all()->take(5);
     return view('home', compact('games', 'NewGames', 'FeatGames'));
 }
 public function challenges()
 {
     $startd = DB::table('Games')->select('start')->first();
     $endd = DB::table('Games')->select('stop')->first();
     if ($startd->start > Carbon::now()) {
         return view("pages.countdown");
     } elseif ($endd->stop < Carbon::now()) {
         return view('pages.closed');
     }
     $num_users = User::count();
     $completed = Submitted_flag::count();
     $num_challenges = Challenge::count();
     $average_c = $completed / $num_users / $num_challenges * 100;
     $stats = array('num_users' => $num_users, 'completed' => $completed, 'average' => $average_c);
     $mycompleted = Submitted_flag::where('user_id', Auth::user()->id)->get()->toArray();
     $game = Game::first();
     $categories = Category::get();
     $categories = $categories->toArray();
     foreach ($categories as $category) {
         $challenges = Challenge::where('category_id', $category['id'])->orderby('point_value', 'ASC')->get()->toArray();
         $categories[(int) $category['id'] - 1]['challenges'] = $challenges;
     }
     $directory = base_path() . '/public/Challenges_Repo/';
     $files = scandir($directory);
     $startd = DB::table('Games')->select('start')->first();
     if ($startd->start > Carbon::now()) {
         $start = true;
     } else {
         $start = false;
     }
     $data = array('user' => Auth::user(), 'game' => $game, 'categories' => $categories, 'stats' => $stats, 'files' => $files, 'completed' => $mycompleted, 'start' => $start);
     return view("pages.challenges")->with('data', $data);
 }
 public function destroy($id)
 {
     // delete
     $game = Game::find($id);
     $game->delete();
     return redirect('games');
 }
 public function scoreboard()
 {
     $results = DB::select(DB::raw("select users.name as name, sum(challenges.point_value) as Total from users\n                                        inner join submitted_flags\n                                        on submitted_flags.user_id = users.id\n                                        inner join challenges\n                                        on challenges.id = submitted_flags.challenge_id\n                                        group by users.name\n                                        order by Total DESC"));
     $game = Game::first();
     $data = array('game' => $game, 'scores' => $results);
     return view('pages.scoreboard')->with('data', $data);
 }
 public function postCalculateMatch($slug, $id, Request $request)
 {
     $tournament = KTournament::enabled()->whereSlug($slug)->first();
     $match = KMatch::find($id);
     if (!$tournament || !$match) {
         abort(404);
     }
     //If has enough permissions or not
     if (!$request->user()->canManageTournament($tournament)) {
         return redirect()->home();
     }
     if ($match->has_been_played) {
         return redirect()->route('tournament.bracket.show', [$tournament->slug])->with('error', "Error! Already calculated, Plz contact admin for support");
     }
     $collection = new Collection();
     $i = 1;
     foreach ($request->game_id as $game_id) {
         //If game_id is 0 means game is not played
         if ($game_id == 0) {
             $game = new Game();
             $game->game_index = $i;
             $game->is_played = false;
         } else {
             //Get the game
             $game = Game::findOrFail($game_id);
             $game->game_index = $i;
             $game->is_played = true;
         }
         $i++;
         $collection->push($game);
     }
     //dd($collection);
     return view('tournament.manage.getcalculate2')->with('tournament', $tournament)->with('match', $match)->with('games', $collection);
 }
 public function show($id)
 {
     $game = Game::with('playthroughs', 'playthroughs.players')->find($id);
     $bgg = new \App\Bgg();
     $api = $bgg->getBoardGame($game->bgg_id);
     return view('game.show', ['game' => $game, 'details' => $api]);
 }
Beispiel #11
0
 /**
  * Fills games table
  *
  */
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Game::create(['name' => $faker->name(), 'abbreviation' => $faker->realText(10), 'type' => $faker->realText(100), 'description' => $faker->realText(255)]);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('games')->delete();
     Game::create(['id' => 1, 'score1' => 15, 'score2' => 0, 'minutes' => 10]);
     Game::create(['id' => 2, 'score1' => 15, 'score2' => 14, 'minutes' => 27]);
     Game::create(['id' => 3, 'score1' => 15, 'score2' => 4, 'minutes' => 20]);
     Game::create(['id' => 4, 'score1' => 15, 'score2' => 4, 'minutes' => 22]);
     Game::create(['id' => 5, 'score1' => 15, 'score2' => 10, 'minutes' => 33]);
     Game::create(['id' => 6, 'score1' => 15, 'score2' => 7, 'minutes' => 28]);
     /** Alexandra H. Battle Alamo */
     /** Pro Rnd 1*/
     Game::create(['id' => 7, 'score1' => 11, 'score2' => 7, 'minutes' => 28]);
     Game::create(['id' => 8, 'score1' => 11, 'score2' => 8, 'minutes' => 28]);
     Game::create(['id' => 9, 'score1' => 11, 'score2' => 8, 'minutes' => 28]);
     /** Pro Rnd 2*/
     Game::create(['id' => 10, 'score1' => 11, 'score2' => 9, 'minutes' => 28]);
     Game::create(['id' => 11, 'score1' => 11, 'score2' => 7, 'minutes' => 28]);
     Game::create(['id' => 12, 'score1' => 2, 'score2' => 11, 'minutes' => 28]);
     Game::create(['id' => 13, 'score1' => 15, 'score2' => 13, 'minutes' => 28]);
     /** Open Rnd 1 */
     Game::create(['id' => 14, 'score1' => 15, 'score2' => 1, 'minutes' => 10]);
     Game::create(['id' => 15, 'score1' => 15, 'score2' => 0, 'minutes' => 8]);
     /** Open Rnd 2 */
     Game::create(['id' => 16, 'score1' => 15, 'score2' => 3, 'minutes' => 19]);
     Game::create(['id' => 17, 'score1' => 15, 'score2' => 1, 'minutes' => 14]);
     /** Open Rnd 3 */
     Game::create(['id' => 18, 'score1' => 15, 'score2' => 4, 'minutes' => 22]);
     Game::create(['id' => 19, 'score1' => 15, 'score2' => 2, 'minutes' => 17]);
     /** Open Rnd 4 */
     Game::create(['id' => 20, 'score1' => 15, 'score2' => 13, 'minutes' => 36]);
     Game::create(['id' => 21, 'score1' => 15, 'score2' => 11, 'minutes' => 32]);
 }
 public function challenges()
 {
     /*$game = Game::first();
             $categories = Category::get();
             $categories = $categories->toArray();
     
             foreach($categories as $category)
             {
                 $challenges = Challenge::where('category_id', $category['id'])->get()->toArray();
                 $categories[(int)$category['id'] - 1]['challenges'] =  $challenges;
             }
     
     
             $data = array('game' => $game, 'categories' => $categories);*/
     $num_users = User::count();
     $completed = Submitted_flag::count();
     $num_challenges = Challenge::count();
     $average_c = $completed / $num_users / $num_challenges * 100;
     $stats = array('num_users' => $num_users, 'completed' => $completed, 'average' => $average_c);
     $game = Game::first();
     $categories = Category::get();
     $categories = $categories->toArray();
     foreach ($categories as $category) {
         $challenges = Challenge::where('category_id', $category['id'])->get()->toArray();
         $categories[(int) $category['id'] - 1]['challenges'] = $challenges;
     }
     $directory = base_path() . '/public/Challenges_Repo/';
     $files = scandir($directory);
     $data = array('user' => Auth::user(), 'game' => $game, 'categories' => $categories, 'stats' => $stats, 'files' => $files);
     return view("pages.challenges")->with('data', $data);
 }
	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('packages', function(Blueprint $table)
		{
			$table->increments('id');
            $table->integer('game_id')->unsigned();
            $table->string('name')->unique();
            $table->string('status')->nullable();
			$table->timestamps();

            $table->foreign('game_id')
                  ->references('id')
                  ->on('games')
                  ->onDelete('cascade');
		});

        $games =  Game::all();
        foreach ($games as $i=>$game) {
            $temp = str_replace('http://www.9apps.com/jump/down/', '', $game->download);
            $temp = str_replace('/app/', '', $temp);

            $check = Package::where('name', $temp)->first();
            if (!$check) {
                Package::create([
                    'game_id' => $game->id,
                    'name' => $temp
                ]);
            }
        }

	}
 public function getShow($gameId)
 {
     $game = Game::findOrFail($gameId);
     $account = Account::where('user_id', '=', Auth::user()->id)->where('game_id', '=', $gameId)->first();
     $servers = $game->servers()->paginate(10);
     return view('game.show', ['game' => $game, 'account' => $account, 'servers' => $servers, 'page_title' => 'Game Detail']);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $dt = new DateTime();
     $req = $request->all();
     $User = [];
     $Game = [];
     $User = User::where('facebook_id', $req["facebook_id"])->get();
     $position_longitude = "-70.584075208";
     $position_latitude = "-33.415208";
     $full_name = $req["full_name"];
     if ($User->count() > 0) {
         $UserNew = $User[0]->user_id;
         $full_name = $User[0]->full_name;
         $new = false;
     } else {
         $UserNew = DB::table('users')->insertGetId(['full_name' => $req["full_name"], 'name' => $req["last_name"], 'facebook_id' => $req["facebook_id"], 'facebook_token' => $req["facebook_token"], 'position_longitude' => $position_longitude, 'position_latitude' => $position_latitude]);
         $new = true;
     }
     $Game = Game::where('user_id', $UserNew)->where('finish', '0000-00-00 00:00:00')->get();
     if ($Game->count() > 0) {
         $GameNew = $Game[0]->game_id;
     } else {
         $GameNew = DB::table('game')->insertGetId(['user_id' => $UserNew, 'start' => $dt->format('y-d-m H:i:s')]);
     }
     return response()->json(array('full_name' => $full_name, 'user_id' => $UserNew, 'game_id' => $GameNew, 'new' => $new));
 }
Beispiel #17
0
 public static function guess($id, $char)
 {
     $game = Game::where('status', self::BUSY)->findOrFail($id);
     $chars = $game->characters_guessed;
     if (in_array(strtolower($char), $chars)) {
         throw (new CharacterUsedException($char . ' has already been used'))->setGame($game);
     }
     if (strpos($game->word, $char) === false) {
         $game->tries_left--;
     }
     $chars[] = $char;
     $game->characters_guessed = $chars;
     if ($game->won()) {
         $game->status = self::SUCCESS;
         $game->save();
         throw (new GameWonException('Congratulations! ' . $game->word . ' is the correct word.'))->setGame($game);
     }
     if ($game->tries_left <= 0) {
         $game->status = self::FAIL;
         $game->save();
         throw (new GameOverException('You lost. The word was: ' . $game->word))->setGame($game);
     }
     $game->save();
     return $game;
 }
Beispiel #18
0
 public function createRoom(Request $request)
 {
     $createGame = Game::prepareCreateGame(Input::all());
     $gameCreated = Game::create($createGame);
     $gameCreated->attachPlayersToGame();
     return Redirect::to('gameLobby');
 }
 /**
  * Fills leagues table
  *
  */
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         $l = League::create(['name' => $faker->name(), 'abbreviation' => $faker->realText(10), 'description' => $faker->realText(150)]);
         $l->game()->associate(Game::first())->save();
         //associate league with first game
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $now = Carbon::now();
     $offset = 0;
     $limit = 100;
     $game = new Game();
     $summary = new GameSummary();
     $client = new Client(['base_uri' => 'https://api.twitch.tv/kraken/', 'headers' => ['Accept' => 'application/vnd.twitchtv.v3+json'], 'timeout' => 5.0]);
     do {
         $summaryArray = [];
         $res = $client->request('GET', 'games/top', ['query' => ['offset' => $offset, 'limit' => $limit]]);
         $body = json_decode($res->getBody(), true);
         // dd($body);
         foreach ($body['top'] as $top) {
             // attempt to find game id
             $game = $game->where('twitch_id', $top['game']['_id'])->first();
             // add game to games table if doesn't exist
             if (!$game) {
                 $game = new Game();
                 $game->twitch_id = $top['game']['_id'];
                 $game->giantbomb_id = $top['game']['giantbomb_id'];
                 $game->name = $top['game']['name'];
                 $game->box_small = $top['game']['box']['small'];
                 $game->box_medium = $top['game']['box']['medium'];
                 $game->box_large = $top['game']['box']['large'];
                 $game->logo_small = $top['game']['logo']['small'];
                 $game->logo_medium = $top['game']['logo']['medium'];
                 $game->logo_large = $top['game']['logo']['large'];
                 $game->save();
             }
             // add game summary data
             $summaryArray[] = ['game_id' => $game->id, 'channels' => $top['channels'], 'viewers' => $top['viewers'], 'created_at' => $now];
         }
         // insert game summary data
         $summary->insert($summaryArray);
         // dd($summaryArray);
         // increment offset
         $offset = $offset + $limit;
     } while (count($body['top']) > 0);
     // insert game summaries
     // $summary->insert($summaryArray);
     echo 'Done';
 }
 /**
  * Rate the specified Game.
  *
  * @param  int  $id
  * @return Response
  */
 public function Rate($id)
 {
     if (isset($_POST['rate']) && !empty($_POST['rate'])) {
         $game = Game::findOrFail($id);
         $rating = new Rating();
         $rating->rating = $_POST['rate'];
         $rating->user_id = Auth::user()->user_id;
         $game->ratings()->save($rating);
     }
 }
 public function overview_games()
 {
     $games = \App\Game::all();
     $gamesFromApi = new GiantBombApi();
     $gamesArray = $gamesFromApi->getAllGames();
     $tweetV = \App\Tweet::getStatusVlambeer();
     $tweetR = \App\Tweet::getStatusRami();
     $tweetJ = \App\Tweet::getStatusJan();
     return view('pages.overview_games', compact('games', 'tweetV', 'tweetR', 'tweetJ', 'gamesArray'));
 }
Beispiel #23
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create('pt_PT');
     /*  $usersNick[] = User::lists('nickname');
         $userCount = User::all()->count();
         $max_nicks = count($usersNick);*/
     for ($i = 0; $i < 5; $i++) {
         Game::insert(array('gameName' => $faker->numerify('Game#####'), 'gameOwner' => $faker->lastName, 'lines' => $faker->numberBetween(2, 10), 'columns' => $faker->numberBetween(2, 10), 'maxPlayers' => $faker->numberBetween(2, 10), 'joinedPlayers' => $faker->numberBetween(0, 2), 'isPrivate' => 0, 'status' => 'Waiting', 'winner' => null));
     }
 }
 /**
  * @param  int  $gameid
  * @return Response
  */
 public function joinagame(Request $request, $gameid)
 {
     Session::put('player', '2');
     Session::put('gameid', $gameid);
     $BS = new BSmodel();
     $BS->joinGame();
     $game = Game::find(Session::get('gameid'));
     PusherLaravel::trigger("{$game->player1id}", 'joined', ['id' => "{$game->player2id}", 'status' => 'joined']);
     return redirect()->route('battleship.game.index');
 }
 public function destroy($gameId)
 {
     try {
         $game = Game::findOrFail($gameId);
         $game->delete();
     } catch (Exception $e) {
         Session::flash('message', 'Fail : ' . $e->getMessage());
         return Redirect::back();
     }
     return Redirect::to(route('admin.game.index'));
 }
Beispiel #26
0
 public function reset()
 {
     $game = null;
     $game_token = session('game_token');
     if ($game_token) {
         $game = Game::where('token', $game_token)->latest()->first();
         $game->finish_at = $game->freshTimestamp();
         $game->save();
         session('game_token', false);
     }
     return response()->json(['status' => true]);
 }
 public function indexGames()
 {
     $games = Game::get();
     $bgg = new \App\Bgg();
     $uploadr = new \App\Uploadr();
     foreach ($games as $game) {
         $url = 'http:' . $bgg->getGameImage($game->bgg_id);
         $path = $uploadr->uploadFromUrl($url, $game->id, 'game');
         $game->photo = $path;
         $game->save();
     }
     return redirect()->back();
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $series = new Series();
     $series->label = $request->label;
     $series->save();
     $game1 = new Game();
     $game1->score = $request->game1score;
     $game1->series_id = $series->id;
     $game1->series_game_number = 1;
     $game1->save();
     $game2 = new Game();
     $game2->score = $request->game2score;
     $game2->series_id = $series->id;
     $game2->series_game_number = 2;
     $game2->save();
     $game3 = new Game();
     $game3->score = $request->game3score;
     $game3->series_id = $series->id;
     $game3->series_game_number = 3;
     $game3->save();
     return Redirect::route('series.index')->with('message', 'Series added');
 }
	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::table('games', function(Blueprint $table)
		{
			$table->string('slug', 32);
		});
        $games = Game::all();
        foreach( $games as $item )
        {
            $item->slug = Str::limit( Str::slug( $item->title), 32, '');
            $item->save();
        }
	}
Beispiel #30
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $lien = $this->argument('lien');
     $id = $this->argument('id');
     if (is_array($lien)) {
         $lien = $lien[0];
     }
     $game = xml_chp_renc($lien);
     foreach ($game->joueur as $joueur) {
         $compo = Composition::where('round_id', $id)->where('xja', $joueur->xja)->where('xjb', $joueur->xjb)->first();
         if ($compo == null) {
             $compo = new Composition();
         }
         $compo->round_id = $id;
         $compo->xja = $joueur->xja;
         $compo->xca = $joueur->xca;
         $compo->xjb = $joueur->xjb;
         $compo->xcb = $joueur->xcb;
         $compo->save();
     }
     Game::where('round_id', $id)->update(['active' => 0]);
     $i = 1;
     foreach ($game->partie as $partie) {
         $game = Game::where('round_id', $id)->where('game', $i)->first();
         if ($game == null) {
             $game = new Game();
         }
         $game->round_id = $id;
         $game->game = $i;
         $game->ja = $partie->ja;
         $game->scorea = $partie->scorea;
         $game->jb = $partie->jb;
         $game->scoreb = $partie->scoreb;
         $game->active = 1;
         $game->save();
         $i++;
     }
 }