/** * Show reward * GET * * @param int $id * @param string $name * @return Response */ public function showObject($id, $name) { $item = RewardManager::join('item_template', 'item_template.id', '=', 'item')->where('item', $id)->first(); $nextRewards = RewardManager::join('item_template', 'item_template.id', '=', 'item')->where('votes', '>', $item->votes)->take(4)->get(); $players = PlayerManager::where('account', Auth::user()->guid)->orderBy('xp', 'asc')->get(); return view('rewards.object', compact('item', 'nextRewards', 'players')); }
public function testCreateAndNewRecordSave() { $player = Player::create(['name' => 'foo']); /* * typeを明示しなければ各クラスで定義されたフィールドを持ち、 * typeには呼び出したクラス名が挿入される */ $this->assertInstanceOf('App\\Model\\Player', $player); $this->assertEquals(['name' => 'foo', 'type' => 'Player', 'id' => $player->id], Player::read($player->id)->getData()); $footballer = FootBaller::create(); $this->assertInstanceOf('App\\Model\\FootBaller', $footballer); $this->assertEquals(['name' => null, 'type' => 'FootBaller', 'club' => null, 'id' => $footballer->id], Player::read($footballer->id)->getData()); $cricketer = Player::newRecord(['name' => 'bar', 'type' => 'Cricketer', 'batting_average' => 10]); print_r($cricketer); $this->assertInstanceOf('App\\Model\\Cricketer', $cricketer); $this->assertEquals(true, $cricketer->save()); $this->assertEquals(['name' => 'bar', 'type' => 'Cricketer', 'batting_average' => 10, 'id' => $cricketer->id], Player::read($cricketer->id)->getData()); $bowller = Player::create(['name' => 'bar', 'type' => 'Bowller', 'batting_average' => 10]); $bowller->bowling_average = 100; $this->assertInstanceOf('App\\Model\\Bowller', $bowller); $this->assertEquals(['name' => 'bar', 'type' => 'Bowller', 'batting_average' => 10, 'bowling_average' => 100, 'id' => $bowller->id], Bowller::read($bowller->id)->getData()); /* * update */ $bowller->name = 'modified'; $this->assertEquals(true, $bowller->save()); $this->assertEquals(['name' => 'modified', 'type' => 'Bowller', 'batting_average' => 10, 'bowling_average' => 100, 'id' => $bowller->id], Player::read($bowller->id)->getData()); }
/** * Show honor ladder * GET * * @return Response */ public function showHonor() { $players = Cache::remember('ladderHonor', 60, function () { return PlayerManager::orderBy('honor', 'desc')->take(config('config.ladder_limit'))->get(); }); return view('ladder.honor', compact('players')); }
/** * Show honor ladder * GET * * @return Response */ public function ShowPvp() { $players = Cache::remember('ladderPvP', 60, function () { return PlayerManager::orderBy('honor', 'desc')->take(50)->get(); }); return view('ladder.pvp', compact('players')); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param string|null $guard * @return mixed */ public function handle($request, Closure $next) { $player = Player::find($request->id); if (Auth::guest() || $player->account != Auth::user()->guid) { return response()->view('errors.404'); } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param string|null $guard * @return mixed */ public function handle($request, Closure $next) { $player = Player::find($request->id); if ($player->private != 1 || Auth::check() && $player->account == Auth::user()->guid) { return $next($request); } return response()->view('errors.404'); }
/** * Show lotery page * GET * * @return Response */ public function showLotery() { $items = ItemManager::where('lotery', 1)->orderByRaw('RAND()')->take(5)->get(); $players = \App\Model\Player::where('account', Auth::user()->guid)->orderBy('xp', 'asc')->get(); return view('points.lotery', compact('items', 'players')); }
/** * Update player's option * POST * * @param Request $request * @param int $id * @param string $name * @return Response */ public function ManageCharacter(Request $request, $id, $name) { $player = PlayerManager::find($id); $player->private = $request->has('private') ? 0 : 1; $player->background = $request->background; $player->presentation = $request->presentation; $player->save(); return redirect()->route('pages.character', [$player->guid, str_slug($player->name)]); }
/** * Show itemset's shop page * GET * * @param int $id * @param string $name * @return Response */ public function showItemset($id, $name) { $itemset = ItemsetManager::find($id); $items = ItemTemplateManager::where('panoplie', $itemset->ID)->orderBy('level', 'desc')->get(); $otherItemsets = ItemsetManager::where('shop', 1)->where('ID', '!=', $itemset->ID)->orderByRaw('RAND()')->take(4)->get(); $players = PlayerManager::where('account', Auth::user()->guid)->orderBy('xp', 'asc')->get(); return view('shop.itemset', compact('itemset', 'items', 'players', 'otherItemsets')); }
/** * Show item shop page * GET * * @param int $id * @param string $name * @return Response */ public function showObject($id, $name) { $item = ItemManager::find($id); $players = PlayerManager::where('account', Auth::user()->guid)->orderBy('level', 'asc')->get(); return view('shop.detail', compact('item', 'players')); }
/** * Show profile * GET * * @return Response */ public function showAccount() { $players = \App\Model\Player::where('account', Auth::user()->guid)->orderBy('xp', 'desc')->get(); return view('user.account', compact('players')); }
/** * Show token of user * GET * * @param int $id * @param string $name * @return Response */ public function showToken($id, $name) { $token = TokensAccountManager::join('cms_tokens', 'cms_tokens.id', '=', 'token')->where('guid', Auth::user()->guid)->where('token', $id)->first(); $players = PlayerManager::where('account', Auth::user()->guid)->get(); $ids = explode(',', $token->items); $objectArray = []; foreach ($ids as $id) { if (!empty($id)) { array_push($objectArray, $id); } } $objects = ItemTemplateManager::whereIn('id', $objectArray)->orderBy('level', 'asc')->get(); return view('tokens.page', compact('token', 'objects', 'players')); }
/** * Show form to validate code * GET * * @param string $key * @return Response */ public function validateCode($key) { $code = CodeManager::find($key); $players = PlayerManager::where('account', Auth::user()->guid)->orderBy('xp', 'asc')->get(); return view('gift.validate', compact('code', 'players')); }